Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (ra == ReorganizingAlgorithm.COUNT) {
- ListItem<T> item = head;
- item.counter = 0;
- while (item.next != null) {
- if (predicate.test(item.next.key)) {
- item.next.counter++;
- }
- // wenn pos 1, groeßte ist
- if (head.next.counter > head.counter) {
- //System.out.println("hier");
- ListItem<T> tmpItem = head;
- ListItem<T> tmpNext = head.next;
- tmpItem.next = head.next.next;
- tmpNext.next = head;
- head = tmpNext;
- break;
- }
- item = item.next;
- } // end while
- } //------------------------------------------
- // if (this.ra == ReorganizingAlgorithm.COUNT) {
- // //checking if list is empty
- // if(head == null) {
- // return null;
- // } else {
- //
- // // creating four pointers
- // ListItem<T> c = head;
- // ListItem<T> z = head;
- // ListItem<T> p = head;
- // ListItem<T> y = head;
- //
- // //lfc=lowestFoundCounter= the value of the lowest found counter so far
- // int lfc = p.counter;
- //
- // //asc=amountOfSameCounters= the amount of elements found with the same counter as the current element
- // int asc = 1;
- //
- //
- // //checking if first item is the searched one
- // if(predicate.test(p.key)) {
- // p.counter++;
- // return head.key;
- // }
- // //checking if next item is the searched one
- // if(predicate.test(p.next.key)) {
- // p.next.counter++;
- // //marking current(=c) element
- // c = p.next;
- //
- // //if item has to be swapped
- // if(lfc < p.next.counter) {
- // while(asc > 0) {
- //
- // //bringing pointers to correct position
- // y.next=c;
- // p.next=c;
- // z=c;
- //
- // //swapping places
- // p.next = p.next.next;
- // z.next = z.next.next;
- // p.next.next=z;
- // z.next=p;
- // asc--;
- // }
- // }
- // }
- //
- // //if counters of current and next item are the same, increase asc.
- // if (p.counter == p.next.counter) {
- // asc++;
- // }
- //
- // else {
- // asc=1;
- // }
- // p = p.next;
- // }
- //
- // return null;
- //
- // }
- //
- //
- // return null;
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement