Skip to content

Commit b157f34

Browse files
Владимир СеверовВладимир Северов
authored andcommitted
17.04.18 16:54 - std adapter added
1 parent b2790fb commit b157f34

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

HW-1/HW-1/Source.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ void hasher() {
88

99
int main()
1010
{
11-
/* std::unordered_set *
12-
std::unordered_set<int> test;
11+
/* std::unordered_set */
12+
std_unordered_set<int> test;
1313
test.max_load_factor(2);
1414
std::cout << test.empty() << std::endl;
1515
for (int i = 0; i < 10; i++) {
@@ -34,7 +34,7 @@ int main()
3434
std::cout << *(--test.end()) << std::endl;
3535
test.erase(2);
3636
std::cout << test.size() << " " << test.bucket_count() << std::endl;
37-
std::unordered_set<int> test_copy(test);
37+
std_unordered_set<int> test_copy(test);
3838
std::cout << test.empty() << std::endl;
3939
test.clear();
4040
std::cout << test.empty() << std::endl;
@@ -47,6 +47,7 @@ int main()
4747
std::cout << test.size() << " " << test.bucket_count() << std::endl << std::endl;
4848
/**/
4949

50+
/*
5051
UnorderedSet<int> test_2;
5152
test_2.MaxLoadFactor(2);
5253
std::cout << test_2.Empty() << std::endl;
@@ -84,7 +85,8 @@ int main()
8485
std::cout << test_2.Size() << " " << test_2.BucketCount() << std::endl;
8586
test_2.Rehash(100);
8687
std::cout << test_2.Size() << " " << test_2.BucketCount() << std::endl << std::endl;
87-
88+
/**/
89+
8890
system("pause");
8991
return 0;
9092
}

HW-1/HW-1/UnorderedSet.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,4 +617,52 @@ template< class Key, class Hash, class KeyEqual >
617617
void swap(UnorderedSet<Key, Hash, KeyEqual>& lhs, UnorderedSet<Key, Hash, KeyEqual>& rhs)
618618
{
619619
lhs.swap(rhs);
620-
}
620+
}
621+
622+
template< class Key,
623+
class Hash = std::hash<Key>,
624+
class KeyEqual = std::equal_to<Key>
625+
> class std_unordered_set
626+
: public UnorderedSet<Key, Hash, KeyEqual>
627+
{
628+
public:
629+
iterator begin() { return Begin(); }
630+
const_iterator begin() const { return Begin(); }
631+
const_iterator cbegin() const { return CBegin(); }
632+
iterator end() { return End(); }
633+
const_iterator end() const { return End(); }
634+
const_iterator cend() const { return CEnd(); }
635+
bool empty() const { return Empty(); }
636+
size_type size() const { return Size(); }
637+
size_type max_size() const { return MaxSize(); }
638+
void clear() { Clear(); }
639+
std::pair<iterator, bool> insert(const value_type& value) { return Insert(value); }
640+
void insert(iterator first, iterator last) { Insert(first, last); }
641+
void insert(std::initializer_list<value_type> initList) { Insert(initList); }
642+
iterator erase(const_iterator position) { return Erase(position); }
643+
iterator erase(const_iterator first, const_iterator last) { return Erase(first, last); }
644+
size_type erase(const value_type& value) { return Erase(value); }
645+
void swap(UnorderedSet& other) { Swap(other); }
646+
size_type count(const value_type& value) const { return count(value); }
647+
iterator find(const value_type& value) { return Find(value); }
648+
const_iterator find(const value_type& value) const { return Find(value); }
649+
std::pair<iterator, iterator> equal_range(const value_type& value) { return EqualRange(value); }
650+
std::pair<const_iterator, const_iterator> equal_range(const value_type& value) const { return EqualRange(value); }
651+
iterator begin(size_type n) { return Begin(n); }
652+
const_iterator begin(size_type n) const { return Begin(n); }
653+
const_iterator cbegin(size_type n) const { return CBegin(n); }
654+
iterator end(size_type n) { return End(n); }
655+
const_iterator end(size_type n) const { return End(n); }
656+
const_iterator cend(size_type n) const { return CEnd(n); }
657+
size_type bucket_count() const { return BucketCount(); }
658+
size_type max_bucket_count() const { return MaxBucketCount(); }
659+
size_type bucket_size(size_type n) const { return BucketSize(n); }
660+
size_type bucket(const value_type& value) const { return Bucket(value); }
661+
float load_factor() const { return LoadFactor(); }
662+
float max_load_factor() const { return MaxLoadFactor(); }
663+
void max_load_factor(float ml) { MaxLoadFactor(ml); }
664+
void rehash(size_type count) { Rehash(count); }
665+
void reserve(size_type count) { Reserve(count); }
666+
hasher hash_function() const { return HashFunction(); }
667+
key_equal key_eq() const { return KeyEq(); }
668+
};

0 commit comments

Comments
 (0)