aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/containers
diff options
context:
space:
mode:
authorStanislav Kirillov <staskirillov@gmail.com>2022-02-10 16:46:07 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:07 +0300
commit92fe2b1e7bc79f7b95adef61714fc003f6ea4a1c (patch)
tree817034f4ca57c9f841bb047ec94630c2e78a2b1d /library/cpp/containers
parent53c76da6d9f6cc5a17f6029df396f0e3bc1ff47d (diff)
downloadydb-92fe2b1e7bc79f7b95adef61714fc003f6ea4a1c.tar.gz
Restoring authorship annotation for Stanislav Kirillov <staskirillov@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers')
-rw-r--r--library/cpp/containers/2d_array/2d_array.h32
-rw-r--r--library/cpp/containers/2d_array/ya.make2
2 files changed, 17 insertions, 17 deletions
diff --git a/library/cpp/containers/2d_array/2d_array.h b/library/cpp/containers/2d_array/2d_array.h
index 9e24650637..5ecd0fb84e 100644
--- a/library/cpp/containers/2d_array/2d_array.h
+++ b/library/cpp/containers/2d_array/2d_array.h
@@ -7,12 +7,12 @@
template <class T>
struct TBoundCheck {
T* Data;
- size_t Size;
- TBoundCheck(T* d, size_t s) {
+ size_t Size;
+ TBoundCheck(T* d, size_t s) {
Data = d;
Size = s;
}
- T& operator[](size_t i) const {
+ T& operator[](size_t i) const {
Y_ASSERT(i >= 0 && i < Size);
return Data[i];
}
@@ -25,15 +25,15 @@ private:
typedef T* PT;
T* Data;
T** PData;
- size_t XSize;
- size_t YSize;
+ size_t XSize;
+ size_t YSize;
private:
void Copy(const TArray2D& a) {
XSize = a.XSize;
YSize = a.YSize;
Create();
- for (size_t i = 0; i < XSize * YSize; i++)
+ for (size_t i = 0; i < XSize * YSize; i++)
Data[i] = a.Data[i];
}
void Destroy() {
@@ -43,12 +43,12 @@ private:
void Create() {
Data = new T[XSize * YSize];
PData = new PT[YSize];
- for (size_t i = 0; i < YSize; i++)
+ for (size_t i = 0; i < YSize; i++)
PData[i] = Data + i * XSize;
}
public:
- TArray2D(size_t xsize = 1, size_t ysize = 1) {
+ TArray2D(size_t xsize = 1, size_t ysize = 1) {
XSize = xsize;
YSize = ysize;
Create();
@@ -64,7 +64,7 @@ public:
~TArray2D() {
Destroy();
}
- void SetSizes(size_t xsize, size_t ysize) {
+ void SetSizes(size_t xsize, size_t ysize) {
if (XSize == xsize && YSize == ysize)
return;
Destroy();
@@ -76,27 +76,27 @@ public:
SetSizes(1, 1);
}
#ifdef _DEBUG
- TBoundCheck<T> operator[](size_t i) const {
+ TBoundCheck<T> operator[](size_t i) const {
Y_ASSERT(i < YSize);
return TBoundCheck<T>(PData[i], XSize);
}
#else
- T* operator[](size_t i) const {
+ T* operator[](size_t i) const {
Y_ASSERT(i < YSize);
return PData[i];
}
#endif
- size_t GetXSize() const {
+ size_t GetXSize() const {
return XSize;
}
- size_t GetYSize() const {
+ size_t GetYSize() const {
return YSize;
}
void FillZero() {
memset(Data, 0, sizeof(T) * XSize * YSize);
}
void FillEvery(const T& a) {
- for (size_t i = 0; i < XSize * YSize; i++)
+ for (size_t i = 0; i < XSize * YSize; i++)
Data[i] = a;
}
void Swap(TArray2D& a) {
@@ -111,8 +111,8 @@ template <class T>
inline bool operator==(const TArray2D<T>& a, const TArray2D<T>& b) {
if (a.GetXSize() != b.GetXSize() || a.GetYSize() != b.GetYSize())
return false;
- for (size_t y = 0; y < a.GetYSize(); ++y) {
- for (size_t x = 0; x < a.GetXSize(); ++x)
+ for (size_t y = 0; y < a.GetYSize(); ++y) {
+ for (size_t x = 0; x < a.GetXSize(); ++x)
if (a[y][x] != b[y][x])
return false;
}
diff --git a/library/cpp/containers/2d_array/ya.make b/library/cpp/containers/2d_array/ya.make
index 71d56b902f..fe5e2f649b 100644
--- a/library/cpp/containers/2d_array/ya.make
+++ b/library/cpp/containers/2d_array/ya.make
@@ -1,7 +1,7 @@
LIBRARY()
OWNER(kirillovs)
-
+
SRCS(
2d_array.cpp
)