АкушерствоАнатомияАнестезиологияВакцинопрофилактикаВалеологияВетеринарияГигиенаЗаболеванияИммунологияКардиологияНеврологияНефрологияОнкологияОториноларингологияОфтальмологияПаразитологияПедиатрияПервая помощьПсихиатрияПульмонологияРеанимацияРевматологияСтоматологияТерапияТоксикологияТравматологияУрологияФармакологияФармацевтикаФизиотерапияФтизиатрияХирургияЭндокринологияЭпидемиология

Queues in C#

A queue is a collection where elements are processed first in, first out (FIFO). The item that is put first in the queue is read first. Examples of queues are standing in the queue at the airport, a human resources

queue to process employee applicants, print jobs waiting to be processed in a print queue, and a thread waiting for the CPU in a round - robin fashion. Often, there are queues where the elements processed

differ in their priority. For example, in the queue at the airport, business passengers are processed before economy passengers. Here, multiple queues can be used, one queue for every priority. At the airport this

can easily be found out, because there are separate check - in queues for business and economy passengers. The same is true for print queues and threads. You can have an array or a list of queues where one item

in the array stands for a priority. Within every array item there ’ s a queue, where processing happens with the FIFO principle.

A queue is implemented with the Queue < T >class in the namespace System.Collections.Generic. Internally, the Queue < T >class is using an array of type T, similar to the List < T >type. It implements the interfaces IEnumerable < T >and ICollection, but not ICollection < T >. ICollection < T >is not implemented because this interface defines Add() and Remove() methods which should not be available for queues.

The Queue < T >class does not implement the interface IList < T >, so you cannot access the queue using an indexer. The queue just allows you to add an item to the queue, where the item is put at the end of the

queue (with the Enqueue() method), and to get items from the head of the queue (with the Dequeue() method).


Дата добавления: 2015-09-18 | Просмотры: 520 | Нарушение авторских прав



1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |



При использовании материала ссылка на сайт medlec.org обязательна! (0.002 сек.)