Beispiel #1
0
 public HashST1(int M)
 {
     this.M    = M;
     N         = 0;
     hashtable = new LinkedList1 <Key> [M];
     for (int i = 0; i < M; i++)
     {
         hashtable[i] = new LinkedList1 <Key>();
     }
 }
Beispiel #2
0
        public void Remove(Key key)
        {
            LinkedList1 <Key> list = hashtable[Hash(key)];

            if (list.Contains(key))
            {
                list.Remove(key);
                N--;
            }
        }
Beispiel #3
0
        public void Add(Key key)
        {
            LinkedList1 <Key> list = hashtable[Hash(key)];

            if (list.Contains(key))
            {
                return;
            }
            else
            {
                list.AddFirst(key);
                N++;
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            LinkedList1 <int> l = new LinkedList1 <int>();

            for (int i = 0; i < 5; i++)
            {
                l.AddFirst(i);
                Console.WriteLine(l);
            }

            l.AddLast(666);
            Console.WriteLine(l);

            l.Add(2, 999);
            Console.WriteLine(l);

            l.Set(2, 1000);
            Console.WriteLine(l);

            Console.Read();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            LinkedList1 <int> l = new LinkedList1 <int>();

            for (int i = 0; i < 5; i++)
            {
                l.AddFirst(i);
                Console.WriteLine(l);
            }

            l.AddLast(666);
            Console.WriteLine(l);

            l.Add(2, 999);
            Console.WriteLine(l);

            l.Set(2, 1000);
            Console.WriteLine(l);

            //4->3->1000->2->1->0->666->Null

            l.RemoveAt(2);
            Console.WriteLine(l);

            l.RemoveFirst();
            Console.WriteLine(l);

            l.RemoveLast();
            Console.WriteLine(l);

            l.Remove(0);
            Console.WriteLine(l);



            Console.Read();
        }
Beispiel #6
0
 public LinkedList1Set()
 {
     list = new LinkedList1 <E>();
 }
Beispiel #7
0
        public bool Contains(Key key)
        {
            LinkedList1 <Key> list = hashtable[Hash(key)];

            return(list.Contains(key));
        }
Beispiel #8
0
 //构造函数初始化链表
 public LinkedList1Stack()
 {
     list = new LinkedList1 <E>();
 }
Beispiel #9
0
 public LinkedList1Queue()
 {
     list = new LinkedList1 <E>();
 }