aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorSergey Lisitsyn <lisitsyn@hey.com>2022-02-10 16:48:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:19 +0300
commit193231612b72d126ed21bc6b76b1a5206066a868 (patch)
treeb222e5ac2e2e98872661c51ccceee5da0d291e13 /util/generic
parentc9e1915ecc1c41fac307cfc13afbd8b06c44f3df (diff)
downloadydb-193231612b72d126ed21bc6b76b1a5206066a868.tar.gz
Restoring authorship annotation for Sergey Lisitsyn <lisitsyn@hey.com>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/map.pxd92
-rw-r--r--util/generic/map_ut.pyx164
-rw-r--r--util/generic/ptr.h2
3 files changed, 129 insertions, 129 deletions
diff --git a/util/generic/map.pxd b/util/generic/map.pxd
index 3d9e2bdb91..5c9fc32804 100644
--- a/util/generic/map.pxd
+++ b/util/generic/map.pxd
@@ -1,46 +1,46 @@
-from libcpp.pair cimport pair
-
-cdef extern from "util/generic/map.h" nogil:
- cdef cppclass TMap[T, U]:
- cppclass iterator:
- pair[T, U]& operator*()
- iterator operator++()
- iterator operator--()
- bint operator==(iterator)
- bint operator!=(iterator)
-
- cppclass const_iterator(iterator):
- pass
-
- TMap() except +
- TMap(TMap&) except +
- U& operator[](T&)
- TMap& operator=(TMap&)
-
- bint operator==(TMap&)
- bint operator!=(TMap&)
- bint operator<(TMap&)
- bint operator>(TMap&)
- bint operator<=(TMap&)
- bint operator>=(TMap&)
-
- U& at(T&) except +
- iterator begin()
- const_iterator const_begin "begin"()
- void clear()
- size_t count(T&)
- bint empty()
- iterator end()
- const_iterator const_end "end"()
- pair[iterator, iterator] equal_range(T&)
- void erase(iterator) except +
- void erase(iterator, iterator) except +
- size_t erase(T&)
- iterator find(T&)
- bint contains(T&)
- const_iterator const_find "find"(T&)
- pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]&
- iterator insert(iterator, pair[T, U]) # XXX pair[T,U]&
- size_t max_size()
- size_t size()
- void swap(TMap&)
+from libcpp.pair cimport pair
+
+cdef extern from "util/generic/map.h" nogil:
+ cdef cppclass TMap[T, U]:
+ cppclass iterator:
+ pair[T, U]& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(iterator)
+ bint operator!=(iterator)
+
+ cppclass const_iterator(iterator):
+ pass
+
+ TMap() except +
+ TMap(TMap&) except +
+ U& operator[](T&)
+ TMap& operator=(TMap&)
+
+ bint operator==(TMap&)
+ bint operator!=(TMap&)
+ bint operator<(TMap&)
+ bint operator>(TMap&)
+ bint operator<=(TMap&)
+ bint operator>=(TMap&)
+
+ U& at(T&) except +
+ iterator begin()
+ const_iterator const_begin "begin"()
+ void clear()
+ size_t count(T&)
+ bint empty()
+ iterator end()
+ const_iterator const_end "end"()
+ pair[iterator, iterator] equal_range(T&)
+ void erase(iterator) except +
+ void erase(iterator, iterator) except +
+ size_t erase(T&)
+ iterator find(T&)
+ bint contains(T&)
+ const_iterator const_find "find"(T&)
+ pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]&
+ iterator insert(iterator, pair[T, U]) # XXX pair[T,U]&
+ size_t max_size()
+ size_t size()
+ void swap(TMap&)
diff --git a/util/generic/map_ut.pyx b/util/generic/map_ut.pyx
index 8f7f280e6a..d6ec29724d 100644
--- a/util/generic/map_ut.pyx
+++ b/util/generic/map_ut.pyx
@@ -1,82 +1,82 @@
-from util.generic.map cimport TMap
-from util.generic.string cimport TString
-
-import pytest
-import unittest
-
-from libcpp.pair cimport pair
-from cython.operator cimport dereference as deref
-
-
-def _check_convert(TMap[TString, int] x):
- return x
-
-
-class TestMap(unittest.TestCase):
-
- def test_constructors_and_assignments(self):
- cdef TMap[TString, int] c1
- c1["one"] = 1
- c1["two"] = 2
- cdef TMap[TString, int] c2 = TMap[TString, int](c1)
- self.assertEqual(2, c1.size())
- self.assertEqual(2, c2.size())
- self.assertEqual(1, c1.at("one"))
- self.assertTrue(c1.contains("two"))
- self.assertTrue(c2.contains("one"))
- self.assertEqual(2, c2.at("two"))
- c2["three"] = 3
- c1 = c2
- self.assertEqual(3, c1.size())
- self.assertEqual(3, c2.size())
- self.assertEqual(3, c1.at("three"))
-
- def test_equality_operator(self):
- cdef TMap[TString, int] base
- base["one"] = 1
- base["two"] = 2
-
- cdef TMap[TString, int] c1 = TMap[TString, int](base)
- self.assertTrue(c1==base)
-
- cdef TMap[TString, int] c2
- c2["one"] = 1
- c2["two"] = 2
- self.assertTrue(c2 == base)
-
- c2["three"] = 3
- self.assertTrue(c2 != base)
-
- cdef TMap[TString, int] c3 = TMap[TString, int](base)
- c3["one"] = 0
- self.assertTrue(c3 != base)
-
- def test_insert_erase(self):
- cdef TMap[TString, int] tmp
- self.assertTrue(tmp.insert(pair[TString, int]("one", 0)).second)
- self.assertFalse(tmp.insert(pair[TString, int]("one", 1)).second)
- self.assertTrue(tmp.insert(pair[TString, int]("two", 2)).second)
- cdef TString one = "one"
- cdef TString two = "two"
- self.assertEqual(tmp.erase(one), 1)
- self.assertEqual(tmp.erase(two), 1)
- self.assertEqual(tmp.size(), 0)
- self.assertTrue(tmp.empty())
-
- def test_iterators_and_find(self):
- cdef TMap[TString, int] tmp
- self.assertTrue(tmp.begin() == tmp.end())
- self.assertTrue(tmp.find("1") == tmp.end())
- tmp["1"] = 1
- self.assertTrue(tmp.begin() != tmp.end())
- cdef TMap[TString, int].iterator it = tmp.find("1")
- self.assertTrue(it != tmp.end())
- self.assertEqual(deref(it).second, 1)
-
- def test_convert(self):
- src = {'foo': 1, 'bar': 42}
- self.assertEqual(_check_convert(src), src)
-
- bad_src = {'foo': 1, 'bar': 'baz'}
- with self.assertRaises(TypeError):
- _check_convert(bad_src)
+from util.generic.map cimport TMap
+from util.generic.string cimport TString
+
+import pytest
+import unittest
+
+from libcpp.pair cimport pair
+from cython.operator cimport dereference as deref
+
+
+def _check_convert(TMap[TString, int] x):
+ return x
+
+
+class TestMap(unittest.TestCase):
+
+ def test_constructors_and_assignments(self):
+ cdef TMap[TString, int] c1
+ c1["one"] = 1
+ c1["two"] = 2
+ cdef TMap[TString, int] c2 = TMap[TString, int](c1)
+ self.assertEqual(2, c1.size())
+ self.assertEqual(2, c2.size())
+ self.assertEqual(1, c1.at("one"))
+ self.assertTrue(c1.contains("two"))
+ self.assertTrue(c2.contains("one"))
+ self.assertEqual(2, c2.at("two"))
+ c2["three"] = 3
+ c1 = c2
+ self.assertEqual(3, c1.size())
+ self.assertEqual(3, c2.size())
+ self.assertEqual(3, c1.at("three"))
+
+ def test_equality_operator(self):
+ cdef TMap[TString, int] base
+ base["one"] = 1
+ base["two"] = 2
+
+ cdef TMap[TString, int] c1 = TMap[TString, int](base)
+ self.assertTrue(c1==base)
+
+ cdef TMap[TString, int] c2
+ c2["one"] = 1
+ c2["two"] = 2
+ self.assertTrue(c2 == base)
+
+ c2["three"] = 3
+ self.assertTrue(c2 != base)
+
+ cdef TMap[TString, int] c3 = TMap[TString, int](base)
+ c3["one"] = 0
+ self.assertTrue(c3 != base)
+
+ def test_insert_erase(self):
+ cdef TMap[TString, int] tmp
+ self.assertTrue(tmp.insert(pair[TString, int]("one", 0)).second)
+ self.assertFalse(tmp.insert(pair[TString, int]("one", 1)).second)
+ self.assertTrue(tmp.insert(pair[TString, int]("two", 2)).second)
+ cdef TString one = "one"
+ cdef TString two = "two"
+ self.assertEqual(tmp.erase(one), 1)
+ self.assertEqual(tmp.erase(two), 1)
+ self.assertEqual(tmp.size(), 0)
+ self.assertTrue(tmp.empty())
+
+ def test_iterators_and_find(self):
+ cdef TMap[TString, int] tmp
+ self.assertTrue(tmp.begin() == tmp.end())
+ self.assertTrue(tmp.find("1") == tmp.end())
+ tmp["1"] = 1
+ self.assertTrue(tmp.begin() != tmp.end())
+ cdef TMap[TString, int].iterator it = tmp.find("1")
+ self.assertTrue(it != tmp.end())
+ self.assertEqual(deref(it).second, 1)
+
+ def test_convert(self):
+ src = {'foo': 1, 'bar': 42}
+ self.assertEqual(_check_convert(src), src)
+
+ bad_src = {'foo': 1, 'bar': 'baz'}
+ with self.assertRaises(TypeError):
+ _check_convert(bad_src)
diff --git a/util/generic/ptr.h b/util/generic/ptr.h
index 4288d3918c..19db0e3ec5 100644
--- a/util/generic/ptr.h
+++ b/util/generic/ptr.h
@@ -499,7 +499,7 @@ public:
}
inline ~TIntrusivePtr() {
- UnRef();
+ UnRef();
}
inline TIntrusivePtr(const TIntrusivePtr& p) noexcept