Simple implementation of the "Data structure" Queue

Source: Internet
Author: User

Simple implementation of the "Data structure" Queue

   Public classXqueue<t>    {        /// <summary>        ///first element/// </summary>        Private StaticXqueueitem<t>_top; /// <summary>        ///last element/// </summary>        Private StaticXqueueitem<t>_last; /// <summary>        ///length/// </summary>        Private int_length; /// <summary>        ///capacity/// </summary>        /// <returns></returns>         Public intCount () {return_length; }        /// <summary>        ///Queue/// </summary>        /// <param name= "T" ></param>         Public voidEnqueue (T t) {varitem =Newxqueueitem<t> {Item =T}; if(_top = =NULL) {_last= _top =item; }            Else{_last. Next=item; Item. Prev=_last; } _length++; }        /// <summary>        ///out Team/// </summary>        /// <returns></returns>         PublicT DeQueue () {if(_length = =0)            {                Throw NewException ("queue is empty"); } t T=_last.            Item; _last=_last.            Prev; returnT; }        Internal classXqueueitem<t>        {            /// <summary>            ///Current Element/// </summary>             PublicT Item; /// <summary>            ///Next Element/// </summary>             PublicXqueueitem<t>Next; /// <summary>            ///an element of the previous/// </summary>             PublicXqueueitem<t>Prev; }    }

Simple implementation of the "Data structure" Queue

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.