C # language basics-Special set,

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.