示例#1
0
        public override string ToString()
        {
            string         res     = "Count:" + count.ToString() + "   ";
            LinkedNode <T> current = head;

            while (current != null)
            {
                res    += current.data.ToString() + "   ";
                current = current.next;
            }
            return(res);
        }
示例#2
0
        public T SearchAtKey(int key)
        {
            LinkedNode <T> current = head;

            while (current != null && current.Key != key)
            {
                current = current.next;
            }
            if (current == null)
            {
                return(default(T));
            }
            else
            {
                return(current.data);
            }
        }
示例#3
0
        public void Add(LinkedNode <T> obj)
        {
            if (head == null)
            {
                head = obj;
                last = head;
                count++;
                return;
            }
            LinkedNode <T> current = head;

            while (current.next != null)
            {
                current = current.next;
            }
            current.next = obj;
            obj.pre      = current;
            last         = current.next;
            count++;
        }
示例#4
0
        public void Add(T obj)
        {
            if (head == null)
            {
                head = new LinkedNode <T>(obj);
                last = head;
                count++;
                return;
            }
            LinkedNode <T> current = head;

            while (current.next != null)
            {
                current = current.next;
            }
            current.next     = new LinkedNode <T>(obj);
            current.next.pre = current;
            last             = current.next;
            count++;
        }
示例#5
0
 public LinkedList(T obj)
 {
     head  = new LinkedNode <T>(obj);
     count = 1;
 }