C# 0 The Complete Reference


ht  were obtained and displayed. First, a collection of the keys was  retrieved by the  Keys



Download 4,07 Mb.
Pdf ko'rish
bet949/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   945   946   947   948   949   950   951   952   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

ht

 were obtained and displayed. First, a collection of the keys was 

retrieved by the 

Keys

 property. Each key was then used to index 



ht

, yielding the value 

associated with each key. Remember, the indexer defined by 

IDictionary

 and implemented 

by

Hashtable

 uses a key as the index.



SortedList

SortedList

 creates a collection that stores key/value pairs in sorted order, based on the 

value of the keys. 

SortedList

 implements the 



IDictionary

,

ICollection

,

IEnumerable

, and 


ICloneable

 interfaces.



SortedList

 has several constructors, including those shown here:

public SortedList( )

public SortedList(IDictionary 



c

)

public SortedList(int 



capacity

)

public SortedList(IComparer 



comp

)

The first constructor builds an empty collection with an initial capacity of zero. The second 



constructor builds a 

SortedList

 that is initialized with the elements of 



c

 and has an initial 

capacity equal to the number of elements

.

 The third constructor builds an empty 



SortedList

that has the initial capacity specified by 



capacity.

 The capacity is the size of the underlying 

array that is used to store the elements. The fourth form lets you specify a comparison 

method that will be used to compare the object contained in the list. This form creates an 

empty collection with an initial capacity of zero.

The capacity of a 



SortedList

 grows automatically as needed when elements are added 

to the list. When the current capacity is exceeded, the capacity is increased. The advantage 

of specifying a capacity when creating a 



SortedList

 is that you can prevent or minimize the 

overhead associated with resizing the collection. Of course, it makes sense to specify an 

initial capacity only if you have some idea of how many elements will be stored.

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

SortedList

 also 


defines several methods of its own. Some of the most commonly used ones are shown in Table 

24-6. To determine if a 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   945   946   947   948   949   950   951   952   ...   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