One
Stack: Stank, FIFO, an assignment, one value, in order.
. Count takes the number of elements in the collection
. Push pushes elements one by one into the collection
Pop sets the element one pop-up collection
. Peek to view an element in a collection
. Clear to empty the collection
Stack st=new stack (); Hay Heap Set initialization
St. Push (0); push-in
St. Pop ();
St. Clear (); clear
Two
Queue collection: Queues, FIFO, an assignment, one value, in order.
. Count takes the number of elements in the collection
. Enqueue into the queue collection
. Dequeue Out Queue Collection
. Peek to view an element in a collection
. Clear to empty the collection
Example a : This collection is not indexed, first go in first
Queue que = new queue (); initialize
Que. Enqueue (0);
Que. Dequeue (); out
Example two : Calculates how many elements are in a collection
int N=que. Count: Counts the number of elements in the collection
shown example Three : Determines whether there is an element in the queue collection
Que. Contains (0); Whether it contains this element
Three
Hash table: Hashtable, advanced out, one assignment, together to value.
Properties and methods:
. Add (,) adds key and element
. Remove () Removes the element inside the parentheses
. Contains () Determine whether there are bracketed elements in the collection
. Count counts the number of elements in the collection
Example one: establishment, assignment, and reading of theHashtable hash table
Using a hash table, initialize first: Hashtable hs = new Hashtable ();
Ht. ADD (0, "Zhang San"); When assigning a value, the keys in the front of the comma are the object class, and the comma is followed by values
Example two: Remove an element and keyanddetermine if there is an element and key in the collection
Ht. Remove (0) remove element with key value 0
Ht. Contains (0); Determines whether the set contains an element with a key value of 0
Example three: Calculates how many elements are in a Hashtable collection. A separate empty statement is attached
int N=HT. Count; Calculate how many elements are in a collection
Ht. Clear (); empty all elements of a set
Example four: Reading keys and elements from a Hashtable collection with an enumeration type
IDictionaryEnumerator IDE = ht. GetEnumerator ();
while (IDE. MoveNext ())
{
Console.WriteLine (IDE. Key+ "" +ide. Value);
}
Read all the contents of the hash table
C # Foundation Special Collection