C# 0 The Complete Reference


PART II C h a p t e r   2 4



Download 4,07 Mb.
Pdf ko'rish
bet987/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   983   984   985   986   987   988   989   990   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 4 :  

C o l l e c t i o n s ,   E n u m e r a t o r s ,   a n d   I t e r a t o r s    

797


HashSet

HashSet

 is a new collection added to the .NET Framework by version 3.5. It supports a 

collection that implements a set. It uses a hash table for storage. 

HashSet

implements

the

ICollection

,

IEnumerable

,

IEnumerable

,

ISerializable

, and 

IDeserializationCallback

 interfaces. 



HashSet

 implements a set in which all elements 

are unique. In other words, duplicates are not allowed. The order of the elements is not 

specified.



HashSet

 defines a full complement of set operations, such as intersection, 

union, and symmetric difference. This makes 

HashSet

 the perfect choice for working 

with sets of objects. 

HashSet

 is a dynamic collection that grows as needed to 

accommodate the elements it must store.

Here are four commonly used constructors defined by 



HashSet

:

public HashSet( )



public HashSet(IEnumerable 

c

)

public HashSet(IEqualityCompare 



comp

)

public HashSet(IEnumerable 



c

, IEqualityCompare 



comp

)

The first form creates an empty set. The second creates a set that contains the elements of 



the collection specified by 

c.

 The third lets you specify the comparer. The fourth creates a set 

that contains the elements in the collection specified by 

c

 and uses the comparer specified 

by

comp.

 There is also a fifth constructor that lets you initialize a set from serialized data.

In addition to the methods defined by the interfaces that it implements

HashSet

defines several of its own, most of which support various set operations. The set operation 

methods defined by 

HashSet

 are shown in Table 24-21. Notice that the arguments to 

these methods are 

IEnumerable

. This means you can pass something other than 

another

HashSet

 as the second set. Most often, however, both operands will be 

instances of 

HashSet

.

In addition to the properties defined by 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   983   984   985   986   987   988   989   990   ...   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