Skip to content

Instantly share code, notes, and snippets.

@rogierslag
Last active August 29, 2015 13:58
Show Gist options
  • Save rogierslag/10382990 to your computer and use it in GitHub Desktop.
Save rogierslag/10382990 to your computer and use it in GitHub Desktop.
public class SortedLinkedList<E extends Comparable<E>> extends LinkedList<E> {
public boolean add(E toAdd) {
int index = 0;
for( ; index<size() ; index++){
E alreadyIn = get(index);
if(toAdd.compareTo(alreadyIn) < 0){
break;
}
}
add(index, personToAdd);
return true;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment