Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DoubleLinkedListOrdenada <ELEMENT extends Comparable<ELEMENT>>
- extends DoubleLinkedList<ELEMENT>implements LinkedListOrdenada<ELEMENT>{
- public DoubleLinkedListOrdenada () {super(); }
- public void addenOrden(ELEMENT item){
- if(this.size()==0) {
- this.head=this.tail = new Node<ELEMENT>(item, null, null);
- ++this.count;
- }else {
- if(item.compareTo(this.head.item) <= 0){
- this.addFirst(item);
- }else {
- if(item.compareTo(this.tail.item)> 0) {
- this.addLast(item);
- }else {
- Node<ELEMENT> skip= this.head;
- while((skip!=null)&&(item.compareTo(skip.item)>0)) {
- skip=skip.next;
- }
- if(skip==null){
- throw new RuntimeException("Algo Esta Raro en el orden de los elementos de la lista...");
- }
- else {
- Node<ELEMENT> temp= new Node<>(item,skip,skip.prev);
- skip.prev.next=temp;
- skip.prev=temp;
- ++ this.count;
- }
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment