C # language basics-Special set,
Special set
I. stack set
Stack: stack, first available and then available, assigned values one by one, values one by one, in order, without Indexing
Attributes and methods:
. Count: obtains the number of elements in the set.
. Push () pushes elements one by one into the collection
. Pop () will pop up a set of elements one by one
. Clear () clear the set
. Peek () view only, do not remove
Note: ss. Pop (); // bring up the last element that enters the set.
Ss. Peek (); // only check the value of the last entry and do not remove it.
Example 1: A Stack is a zombie. It is only available after it is pushed forward.
Example 2: pop-up elements and several elements in the computing set
Example 3: view only, not remove! And calculate the number of elements in the Set, and add the copy set.
Ii. queue set
First-in-first-out, values are assigned one by one, in order.
Attributes and Methods
. Count: obtains the number of elements in the set.
. Enqueue () into the queue set
. Dequeue () output queue set
. Clear set
Example 1: the Queue set does not have an index for this set. It is first available.
Example 2: calculate the number of elements in a set.
Example 3: remove the first data and calculate several elements.
Example 4: read only, do not remove, and calculate the number of elements
Example 5: determine whether an element exists in the queue set
Iii. Hashtable hash table
Values are assigned one by one, but can only be taken together.
Attributes and Methods
. Add (,) Add key and Element
. Remove () Remove the elements in the brackets
. Contains () indicates whether the set contains any element in parentheses.
. Count calculates the number of elements in the set.
Example 1: Create, assign, and read a hashtable hash table
Example 2: remove an element and key, and determine whether there is an element and key in the set.
Example 3: calculate the number of elements in a hash table set. Additional clearing statement
Example 4: Use enumeration to read keys and elements in a hash table set