Special set (examples and exercises for Stack, queue, and hashtable)

Source: Internet
Author: User

Special set: Stack, queue, hashtable

STACK: values are assigned one by one in sequence.

. 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

 

Queue: first-in-first-out, one-in-one value assignment, and one-in-one value, in order.

. Count: obtains the number of elements in the set.

. Enqueue () into the queue set

. Dequeue () output queue set

. Clear clear set

 

Hashtable: comes out first, values are assigned one by one, but values can only be taken together.

. 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: 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 compute several elements in the set.

 

 

Example 4: The queue set does not have an index for this set, so it is first available.

Example 5: calculate the number of elements in the set.

Example 6: remove the first data and calculate several elements.

Example 7: read only, do not remove, and calculate the number of elements

Example 8: determine whether an element exists in the queue set

 

 

 

Example 9: Create, assign, and read a hashtable hash table

Example 10: remove an element and key, and determine whether there is an element and key in the set.

Example 11: calculate the number of elements in a hash table set. Additional clearing statement

Example 12: Use enumeration to read keys and elements in a hash table set

Exercise: workbooks

Special set (examples and exercises for Stack, queue, and hashtable)

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.