|
S++ STL kitapxanasında xeshlash
|
səhifə | 3/3 | tarix | 21.12.2023 | ölçüsü | 22,94 Kb. | | #188538 |
| Xeshlew tu
S++ STL kitapxanasında xeshlash
Xesh keste bul konteyner bolıp oǵan elementlerdi qosıw, óshiriw, izlew ortasha O (1)
quramalılıqta ámelge asıriladı.
Xesh-keste shınjırlı yamasa ashıq bolıwı múmkin.
Shınjırlı kestede tiykarǵı maǵlıwmatqa silteme saqlanadı. Yaǵnıy xesh-kestede maǵlıwmattıń ózi
saqlanmaydi, tek xesh hám siltemeler saqlanadı (bucket).
STL shınjırlı xesh-kesteni unordered_set arqalı realizatsiya etedi.
Metodları :
• insert () - jıynaqǵa element qosıw
• count () - elementler sanın anıqlaw
• find () - elementti qıdırsh
• size () - jıynaq ólshemin anıqlaw
• erase () - jıynaqtan elementti óshiriw
• clear () - barlıq elementlerdi óshiriw
• empty () - jıynaq boslıǵın tekseriw
4-másele. unordered_set tipida xesh-keste jaratıladı hám maǵlıwmatlar kestege juklenedi.
#include
#include
using namespace std;
int main()
{
unordered_set numbers {1, 100, 10, 70, 100};
cout << "numbers = ";
for(auto &num: numbers) {
cout << num << ", ";
}
return 0;
}
Na’tiyje: numbers = 70, 10, 100, 1.
5-ma’sele. Ko’plikke element qosi’w.
#include
#include
using namespace std;
int main() {
unordered_set countries;
countries.insert("Nepal");
countries.insert({"Nepal", "India", "USA", "Korea"});
cout << "Countries = ";
for(const auto& country: countries) {
cout << country << ", ";
}
return 0;
}
Natiyje: Countries = Korea, USA, India, Nepal,
Dostları ilə paylaş: |
|
|