C# 0 The Complete Reference


Dequeue( ) . You can use  Peek( )



Download 4,07 Mb.
Pdf ko'rish
bet958/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   954   955   956   957   958   959   960   961   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Dequeue( )

. You can use 



Peek( )

 to return, but not remove, the next object. An 



InvalidOperationException

 is thrown if you call 



Dequeue( )

 or 


Peek( )

 when the invoking 

queue is empty.

www.freepdf-books.com




770

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

Here is an example that demonstrates 



Queue

:

// Demonstrate the Queue class.



using System;

using System.Collections;

class QueueDemo {

  static void ShowEnq(Queue q, int a) {

    q.Enqueue(a);

    Console.WriteLine("Enqueue(" + a + ")");

    Console.Write("queue: ");

    foreach(int i in q)

      Console.Write(i + " ");

    Console.WriteLine();

  }

  static void ShowDeq(Queue q) {



    Console.Write("Dequeue -> ");

    int a = (int) q.Dequeue();

    Console.WriteLine(a);

    Console.Write("queue: ");

    foreach(int i in q)

      Console.Write(i + " ");

    Console.WriteLine();

  }


  static void Main() {

Method


Description

public vir tual void Clear( )

Sets 

Count


 to zero, which effectively clears 

the queue.

public vir tual bool Contains(object 

v

)

Returns true if 



v

 is in the invoking queue. If 



v

is not found, false is returned.

public vir tual object Dequeue( )

Returns the object at the front of the invoking 

queue. The object is removed in the process.

public vir tual void Enqueue(object 



v

)

Adds 



v

 to the end of the queue.

public vir tual object Peek( )

Returns the object at the front of the invoking 

queue, but does not remove it.

public static Queue Synchronized(Queue 



q

)

Returns a synchronized version of 



q.

public vir tual object[ ] ToArray( )

Returns an array that contains copies of the 

elements of the invoking queue.

public vir tual void TrimToSize( )

Sets 


Capacity

 to 


Count

.

T



ABLE

 24-8 


The Methods Defi ned by 

Queue


www.freepdf-books.com


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   954   955   956   957   958   959   960   961   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish