Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean remove(int number) {
- ListCell prev = null;
- ListCell cell = this.head;
- while (cell != null) {
- if (cell.number == number) {
- if (prev != null) {
- prev.next = cell.next;
- } else {
- // If no prev, already, it is first.
- this.head = this.head.next;
- }
- return true;
- }
- prev = cell;
- cell = cell.next;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement