Exemple #1
0
 public override bool Equals(object obj)
 {
     try
     {
         NodoDoble <T> nodo = obj as NodoDoble <T>;
         return(nodo.Value.Equals(Value));
     }
     catch
     {
         return(false);
     }
 }
Exemple #2
0
        public IEnumerator <T> GetEnumerator()
        {
            NodoDoble <T> current = First;
            int           i       = 0;

            while (current != null && i < Count)
            {
                yield return(current.Value);

                current = current.Next;
                i++;
            }
        }
Exemple #3
0
 public void Sort(Delegate comparer)
 {
     if (Count > 0)
     {
         T[] array = ToArray();
         SortAsArray(array, 0, Count - 1, comparer);
         NodoDoble <T> Temp = First;
         for (int i = 0; i < Count; i++)
         {
             Temp.Value = array[i];
             Temp       = Temp.Next;
         }
     }
 }
Exemple #4
0
        public ListaDoble <T> Search(Predicate <T> anon)
        {
            ListaDoble <T> list = new ListaDoble <T>();
            NodoDoble <T>  Temp = First;
            int            i    = 0;

            do
            {
                if (anon(Temp.Value))
                {
                    list.Add(Temp.Value);
                }
                Temp = Temp.Next;
                i++;
            } while (i < Count);
            return(list);
        }
Exemple #5
0
        public ListaDoble <T> Search(T Value)
        {
            ListaDoble <T> list = new ListaDoble <T>();
            NodoDoble <T>  Temp = First;
            int            i    = 0;

            do
            {
                if (Temp.Value.Equals(Value))
                {
                    list.Add(Temp.Value);
                }
                Temp = Temp.Next;
                i++;
            } while (i < Count);
            return(list);
        }
Exemple #6
0
 public List <T> ToList()
 {
     if (Count == 0)
     {
         return(null);
     }
     else
     {
         List <T>      list = new List <T>();
         int           i    = 0;
         NodoDoble <T> Temp = First;
         do
         {
             list.Add(Temp.Value);
             Temp = Temp.Next;
             i++;
         } while (i < Count);
         return(list);
     }
 }
Exemple #7
0
        public void Add(T Value)
        {
            NodoDoble <T> Temp = new NodoDoble <T>(Value);

            if (Count == 0)
            {
                First      = Temp;
                Last       = Temp;
                First.Next = Last;
                First.Prev = Last;
                Last.Next  = First;
                Last.Prev  = First;
            }
            else
            {
                Temp.Prev  = Last;
                Last.Next  = Temp;
                Temp.Next  = First;
                First.Prev = Temp;
                Last       = Temp;
            }
            Count++;
        }
Exemple #8
0
 public bool Remove(T Value)
 {
     if (Count == 0)
     {
         return(false);
     }
     else
     {
         NodoDoble <T> Temp = First;
         int           i    = 0;
         do
         {
             if (Temp.Value.Equals(Value))
             {
                 if (i == 0)
                 {
                     RemoveFirst();
                     return(true);
                 }
                 if (i == Count - 1)
                 {
                     RemoveLast();
                     return(true);
                 }
                 Temp.Prev.Next = Temp.Next;
                 Temp.Next.Prev = Temp.Prev;
                 Temp           = null;
                 Count--;
                 return(true);
             }
             Temp = Temp.Next;
             i++;
         } while (i < Count);
         return(false);
     }
 }
Exemple #9
0
 public NodoDoble(T Value, NodoDoble <T> Next, NodoDoble <T> Prev)
 {
     this.Value = Value;
     this.Prev  = Prev;
     this.Next  = Next;
 }