aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic
diff options
context:
space:
mode:
authorStanislav Kirillov <staskirillov@gmail.com>2022-02-10 16:46:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:08 +0300
commitcb68f224c46a8ee52ac3fdd2a32534b8bb8dc134 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /util/generic
parent92fe2b1e7bc79f7b95adef61714fc003f6ea4a1c (diff)
downloadydb-cb68f224c46a8ee52ac3fdd2a32534b8bb8dc134.tar.gz
Restoring authorship annotation for Stanislav Kirillov <staskirillov@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'util/generic')
-rw-r--r--util/generic/array_ref.pxd42
-rw-r--r--util/generic/array_ref_ut.pyx56
-rw-r--r--util/generic/hash.pxd6
-rw-r--r--util/generic/hash_set.pxd86
-rw-r--r--util/generic/hash_set_ut.pyx104
-rw-r--r--util/generic/hash_ut.pyx118
-rw-r--r--util/generic/ptr.pxd46
-rw-r--r--util/generic/string.pxd2
-rw-r--r--util/generic/vector.pxd2
9 files changed, 231 insertions, 231 deletions
diff --git a/util/generic/array_ref.pxd b/util/generic/array_ref.pxd
index 47a4b3d8f2..41a4c72d69 100644
--- a/util/generic/array_ref.pxd
+++ b/util/generic/array_ref.pxd
@@ -1,25 +1,25 @@
from libcpp cimport bool as bool_t
-
-cdef extern from "util/generic/array_ref.h" nogil:
- cdef cppclass TArrayRef[T]:
- TArrayRef(...) except +
-
- T& operator[](size_t)
-
+
+cdef extern from "util/generic/array_ref.h" nogil:
+ cdef cppclass TArrayRef[T]:
+ TArrayRef(...) except +
+
+ T& operator[](size_t)
+
bool_t empty()
- T* data() except +
- size_t size() except +
- T* begin() except +
- T* end() except +
-
- cdef cppclass TConstArrayRef[T]:
- TConstArrayRef(...) except +
-
- const T& operator[](size_t)
-
+ T* data() except +
+ size_t size() except +
+ T* begin() except +
+ T* end() except +
+
+ cdef cppclass TConstArrayRef[T]:
+ TConstArrayRef(...) except +
+
+ const T& operator[](size_t)
+
bool_t empty()
- const T* data() except +
- size_t size() except +
- const T* begin() except +
- const T* end() except +
+ const T* data() except +
+ size_t size() except +
+ const T* begin() except +
+ const T* end() except +
diff --git a/util/generic/array_ref_ut.pyx b/util/generic/array_ref_ut.pyx
index 22222fb386..67b69a365c 100644
--- a/util/generic/array_ref_ut.pyx
+++ b/util/generic/array_ref_ut.pyx
@@ -1,28 +1,28 @@
-import pytest
-import unittest
-from util.generic.array_ref cimport TArrayRef
-from util.generic.vector cimport TVector
-
-
-class TestArrayRef(unittest.TestCase):
- def test_array_data_reference(self):
- array_size = 30
- cdef TVector[int] vec
- for i in xrange(array_size):
- vec.push_back(i)
- cdef TArrayRef[int] array_ref = TArrayRef[int](vec.data(), vec.size())
- for i in xrange(array_size / 2):
- array_ref[array_size - 1 - i] = array_ref[i]
- for i in xrange(array_size):
- self.assertEqual(array_ref[i], array_size - 1 - i)
-
- def test_array_vec_reference(self):
- array_size = 30
- cdef TVector[int] vec
- for i in xrange(array_size):
- vec.push_back(i)
- cdef TArrayRef[int] array_ref = TArrayRef[int](vec)
- for i in xrange(array_size / 2):
- array_ref[array_size - 1 - i] = array_ref[i]
- for i in xrange(array_size):
- self.assertEqual(array_ref[i], array_size - 1 - i) \ No newline at end of file
+import pytest
+import unittest
+from util.generic.array_ref cimport TArrayRef
+from util.generic.vector cimport TVector
+
+
+class TestArrayRef(unittest.TestCase):
+ def test_array_data_reference(self):
+ array_size = 30
+ cdef TVector[int] vec
+ for i in xrange(array_size):
+ vec.push_back(i)
+ cdef TArrayRef[int] array_ref = TArrayRef[int](vec.data(), vec.size())
+ for i in xrange(array_size / 2):
+ array_ref[array_size - 1 - i] = array_ref[i]
+ for i in xrange(array_size):
+ self.assertEqual(array_ref[i], array_size - 1 - i)
+
+ def test_array_vec_reference(self):
+ array_size = 30
+ cdef TVector[int] vec
+ for i in xrange(array_size):
+ vec.push_back(i)
+ cdef TArrayRef[int] array_ref = TArrayRef[int](vec)
+ for i in xrange(array_size / 2):
+ array_ref[array_size - 1 - i] = array_ref[i]
+ for i in xrange(array_size):
+ self.assertEqual(array_ref[i], array_size - 1 - i) \ No newline at end of file
diff --git a/util/generic/hash.pxd b/util/generic/hash.pxd
index 458c3cfcae..385c10d805 100644
--- a/util/generic/hash.pxd
+++ b/util/generic/hash.pxd
@@ -34,7 +34,7 @@ cdef extern from "util/generic/hash.h" nogil:
bint operator<=(THashMap&)
bint operator>=(THashMap&)
- U& at(T&) except +
+ U& at(T&) except +
iterator begin()
const_iterator const_begin "begin"()
void clear()
@@ -43,8 +43,8 @@ cdef extern from "util/generic/hash.h" nogil:
iterator end()
const_iterator const_end "end"()
pair[iterator, iterator] equal_range(T&)
- void erase(iterator) except +
- void erase(iterator, iterator) except +
+ void erase(iterator) except +
+ void erase(iterator, iterator) except +
size_t erase(T&)
iterator find(T&)
bint contains(T&)
diff --git a/util/generic/hash_set.pxd b/util/generic/hash_set.pxd
index a53ecf4fe2..d28d90cbe7 100644
--- a/util/generic/hash_set.pxd
+++ b/util/generic/hash_set.pxd
@@ -1,43 +1,43 @@
-from libcpp.pair cimport pair
-
-cdef extern from "util/generic/hash_set.h" nogil:
- cdef cppclass THashSet[T]:
- cppclass iterator:
- T& operator*()
- iterator operator++()
- iterator operator--()
- bint operator==(iterator)
- bint operator!=(iterator)
-
- cppclass const_iterator(iterator):
- pass
-
- THashSet() except +
- THashSet(THashSet&) except +
- THashSet(T* t) except +
- THashSet& operator=(THashSet&)
-
- bint operator==(THashSet&)
- bint operator!=(THashSet&)
- bint operator<(THashSet&)
- bint operator>(THashSet&)
- bint operator<=(THashSet&)
- bint operator>=(THashSet&)
-
- iterator begin()
- const_iterator const_begin "begin"()
- void clear()
- size_t count(T&)
- bint empty()
- iterator end()
- const_iterator const_end "end"()
- 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(T)
- iterator insert(iterator, T)
- size_t size()
- void swap(THashSet&)
+from libcpp.pair cimport pair
+
+cdef extern from "util/generic/hash_set.h" nogil:
+ cdef cppclass THashSet[T]:
+ cppclass iterator:
+ T& operator*()
+ iterator operator++()
+ iterator operator--()
+ bint operator==(iterator)
+ bint operator!=(iterator)
+
+ cppclass const_iterator(iterator):
+ pass
+
+ THashSet() except +
+ THashSet(THashSet&) except +
+ THashSet(T* t) except +
+ THashSet& operator=(THashSet&)
+
+ bint operator==(THashSet&)
+ bint operator!=(THashSet&)
+ bint operator<(THashSet&)
+ bint operator>(THashSet&)
+ bint operator<=(THashSet&)
+ bint operator>=(THashSet&)
+
+ iterator begin()
+ const_iterator const_begin "begin"()
+ void clear()
+ size_t count(T&)
+ bint empty()
+ iterator end()
+ const_iterator const_end "end"()
+ 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(T)
+ iterator insert(iterator, T)
+ size_t size()
+ void swap(THashSet&)
diff --git a/util/generic/hash_set_ut.pyx b/util/generic/hash_set_ut.pyx
index e2d3dfd5c7..bdcf6284af 100644
--- a/util/generic/hash_set_ut.pyx
+++ b/util/generic/hash_set_ut.pyx
@@ -1,53 +1,53 @@
-# cython: c_string_type=str, c_string_encoding=utf8
-
-from util.generic.hash_set cimport THashSet
-from util.generic.string cimport TString
-
-import pytest
-import unittest
-
-from cython.operator cimport dereference as deref
-
-
+# cython: c_string_type=str, c_string_encoding=utf8
+
+from util.generic.hash_set cimport THashSet
+from util.generic.string cimport TString
+
+import pytest
+import unittest
+
+from cython.operator cimport dereference as deref
+
+
class TestHashSet(unittest.TestCase):
-
- def test_simple_constructor_equality_operator(self):
- cdef THashSet[int] c1
- c1.insert(1)
- assert c1.size() == 1
- c1.insert(2)
- c1.insert(2)
- c1.insert(2)
- c1.insert(2)
- assert c1.size() == 2
- assert c1.contains(2)
- assert not c1.contains(5)
- cdef THashSet[int] c2 = c1
- assert c1 == c2
- c1.insert(3)
- assert c1 != c2
- c1.erase(3)
- assert c1 == c2
-
- def test_insert_erase(self):
- cdef THashSet[TString] tmp
- self.assertTrue(tmp.insert("one").second)
- self.assertFalse(tmp.insert("one").second)
- self.assertTrue(tmp.insert("two").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 THashSet[TString] tmp
- self.assertTrue(tmp.begin() == tmp.end())
- self.assertTrue(tmp.find("1") == tmp.end())
- tmp.insert("1")
- self.assertTrue(tmp.begin() != tmp.end())
- cdef THashSet[TString].iterator it = tmp.find("1")
- self.assertTrue(it != tmp.end())
- self.assertEqual(deref(it), "1")
-
+
+ def test_simple_constructor_equality_operator(self):
+ cdef THashSet[int] c1
+ c1.insert(1)
+ assert c1.size() == 1
+ c1.insert(2)
+ c1.insert(2)
+ c1.insert(2)
+ c1.insert(2)
+ assert c1.size() == 2
+ assert c1.contains(2)
+ assert not c1.contains(5)
+ cdef THashSet[int] c2 = c1
+ assert c1 == c2
+ c1.insert(3)
+ assert c1 != c2
+ c1.erase(3)
+ assert c1 == c2
+
+ def test_insert_erase(self):
+ cdef THashSet[TString] tmp
+ self.assertTrue(tmp.insert("one").second)
+ self.assertFalse(tmp.insert("one").second)
+ self.assertTrue(tmp.insert("two").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 THashSet[TString] tmp
+ self.assertTrue(tmp.begin() == tmp.end())
+ self.assertTrue(tmp.find("1") == tmp.end())
+ tmp.insert("1")
+ self.assertTrue(tmp.begin() != tmp.end())
+ cdef THashSet[TString].iterator it = tmp.find("1")
+ self.assertTrue(it != tmp.end())
+ self.assertEqual(deref(it), "1")
+
diff --git a/util/generic/hash_ut.pyx b/util/generic/hash_ut.pyx
index a6db1bbd78..ecf6dac2e6 100644
--- a/util/generic/hash_ut.pyx
+++ b/util/generic/hash_ut.pyx
@@ -1,80 +1,80 @@
# cython: c_string_type=str, c_string_encoding=utf8
from util.generic.hash cimport THashMap
-from util.generic.string cimport TString
-
-import pytest
-import unittest
-
-from libcpp.pair cimport pair
-from cython.operator cimport dereference as deref
-
-
+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(THashMap[TString, int] x):
return x
-class TestHash(unittest.TestCase):
-
- def test_constructors_and_assignments(self):
+class TestHash(unittest.TestCase):
+
+ def test_constructors_and_assignments(self):
cdef THashMap[TString, int] c1
- c1["one"] = 1
- c1["two"] = 2
+ c1["one"] = 1
+ c1["two"] = 2
cdef THashMap[TString, int] c2 = THashMap[TString, int](c1)
- self.assertEqual(2, c1.size())
- self.assertEqual(2, c2.size())
- self.assertEqual(1, c1.at("one"))
+ 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):
+ 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 THashMap[TString, int] base
- base["one"] = 1
- base["two"] = 2
-
+ base["one"] = 1
+ base["two"] = 2
+
cdef THashMap[TString, int] c1 = THashMap[TString, int](base)
- self.assertTrue(c1==base)
-
+ self.assertTrue(c1==base)
+
cdef THashMap[TString, int] c2
- c2["one"] = 1
- c2["two"] = 2
- self.assertTrue(c2 == base)
-
- c2["three"] = 3
- self.assertTrue(c2 != base)
-
+ c2["one"] = 1
+ c2["two"] = 2
+ self.assertTrue(c2 == base)
+
+ c2["three"] = 3
+ self.assertTrue(c2 != base)
+
cdef THashMap[TString, int] c3 = THashMap[TString, int](base)
- c3["one"] = 0
- self.assertTrue(c3 != base)
-
- def test_insert_erase(self):
+ c3["one"] = 0
+ self.assertTrue(c3 != base)
+
+ def test_insert_erase(self):
cdef THashMap[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):
+ 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 THashMap[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())
+ self.assertTrue(tmp.begin() == tmp.end())
+ self.assertTrue(tmp.find("1") == tmp.end())
+ tmp["1"] = 1
+ self.assertTrue(tmp.begin() != tmp.end())
cdef THashMap[TString, int].iterator it = tmp.find("1")
- self.assertTrue(it != tmp.end())
- self.assertEqual(deref(it).second, 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)
diff --git a/util/generic/ptr.pxd b/util/generic/ptr.pxd
index b56edbbfc3..16e8d19144 100644
--- a/util/generic/ptr.pxd
+++ b/util/generic/ptr.pxd
@@ -1,26 +1,26 @@
cdef extern from "<util/generic/ptr.h>" nogil:
cdef cppclass THolder[T]:
- THolder(...)
+ THolder(...)
T* Get()
void Destroy()
T* Release()
- void Reset()
+ void Reset()
void Reset(T*)
- void Swap(THolder[T])
-
-
- cdef THolder[T] MakeHolder[T](...)
-
-
- cdef cppclass TIntrusivePtr[T]:
- TIntrusivePtr()
- TIntrusivePtr(T*)
- TIntrusivePtr& operator=(...)
- void Reset(T*)
- T* Get()
- T* Release()
- void Drop()
-
+ void Swap(THolder[T])
+
+
+ cdef THolder[T] MakeHolder[T](...)
+
+
+ cdef cppclass TIntrusivePtr[T]:
+ TIntrusivePtr()
+ TIntrusivePtr(T*)
+ TIntrusivePtr& operator=(...)
+ void Reset(T*)
+ T* Get()
+ T* Release()
+ void Drop()
+
cdef cppclass TIntrusiveConstPtr[T]:
TIntrusiveConstPtr()
@@ -31,12 +31,12 @@ cdef extern from "<util/generic/ptr.h>" nogil:
void Drop()
- cdef cppclass TAtomicSharedPtr[T]:
- TAtomicSharedPtr()
- TAtomicSharedPtr(T*)
- T& operator*()
- T* Get()
- void Reset(T*)
+ cdef cppclass TAtomicSharedPtr[T]:
+ TAtomicSharedPtr()
+ TAtomicSharedPtr(T*)
+ T& operator*()
+ T* Get()
+ void Reset(T*)
cdef TAtomicSharedPtr[T] MakeAtomicShared[T](...)
diff --git a/util/generic/string.pxd b/util/generic/string.pxd
index 10364659b8..c25f7392a1 100644
--- a/util/generic/string.pxd
+++ b/util/generic/string.pxd
@@ -5,7 +5,7 @@ cdef extern from "<util/generic/strbuf.h>" nogil:
cdef cppclass TStringBuf:
TStringBuf() except +
TStringBuf(const char*) except +
- TStringBuf(const char*, size_t) except +
+ TStringBuf(const char*, size_t) except +
const char* data()
char* Data()
size_t size()
diff --git a/util/generic/vector.pxd b/util/generic/vector.pxd
index 791a15cf9d..99dde95d48 100644
--- a/util/generic/vector.pxd
+++ b/util/generic/vector.pxd
@@ -67,7 +67,7 @@ cdef extern from "<util/generic/vector.h>" nogil:
size_t max_size()
void pop_back() except +
void push_back(T&) except +
- void emplace_back(...) except +
+ void emplace_back(...) except +
reverse_iterator rbegin()
const_reverse_iterator const_rbegin "rbegin"()
reverse_iterator rend()