Esempio n. 1
0
        public object Evict()
        {
            if (this.tail == null)
            {
                return(null);
            }
            object value = this.tail.value;

            this.tail = this.tail.next;
            if (this.tail == null)
            {
                this.head = null;
            }
            else
            {
                this.tail.previous = null;
            }
            return(value);
        }
Esempio n. 2
0
 public void Use(object o)
 {
     MRUList.Node node;
     if (this.head == null)
     {
         node      = new MRUList.Node(o);
         this.head = (this.tail = node);
         return;
     }
     node = this.head;
     while (node != null && !o.Equals(node.value))
     {
         node = node.previous;
     }
     if (node == null)
     {
         node = new MRUList.Node(o);
     }
     else
     {
         if (node == this.head)
         {
             return;
         }
         if (node == this.tail)
         {
             this.tail = node.next;
         }
         else
         {
             node.previous.next = node.next;
         }
         node.next.previous = node.previous;
     }
     this.head.next = node;
     node.previous  = this.head;
     node.next      = null;
     this.head      = node;
 }
Esempio n. 3
0
 public MRUList()
 {
     this.head = (this.tail = null);
 }