-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCells.cpp
143 lines (117 loc) · 2.18 KB
/
Cells.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include "Cells.h"
#include "SValue.h"
Cells::Cells( ValueT data ) : data( std::move( data ) )
{}
Cells::Cells( const Cells& other )
{
*this = other;
}
Cells& Cells::operator=( const Cells& other )
{
if ( this != &other )
{
data.reserve( other.size() );
for ( const auto& i : other.data )
{
data.push_back( std::make_unique< SValue >( *i ) );
}
}
return *this;
}
Cells::Cells( Cells&& other ) noexcept
{
*this = std::move( other );
}
Cells& Cells::operator=( Cells&& other ) noexcept
{
if ( this != &other )
{
data = std::move( other.data );
}
return *this;
}
std::size_t Cells::size() const
{
return data.size();
}
bool Cells::isEmpty() const
{
return data.empty();
}
const Cells::ValueT& Cells::children() const
{
return data;
}
Cells::ValueT& Cells::children()
{
return data;
}
void Cells::append( std::unique_ptr< SValue > v )
{
data.push_back( std::move( v ) );
}
std::unique_ptr< SValue > Cells::takeFront()
{
std::unique_ptr< SValue > front = std::move( data.front() );
data.erase( data.begin() );
return front;
}
void Cells::drop( ValueT::iterator begin, ValueT::iterator end )
{
data.erase( begin, end );
}
void Cells::drop( ValueT::iterator pos )
{
data.erase( pos );
}
void Cells::clear()
{
data.clear();
}
SValue* Cells::front()
{
return data.front().get();
}
const SValue* Cells::front() const
{
return data.front().get();
}
SValue* Cells::back()
{
return data.back().get();
}
const SValue* Cells::back() const
{
return data.back().get();
}
Cells::ValueT::iterator Cells::begin()
{
return data.begin();
}
Cells::ValueT::iterator Cells::end()
{
return data.end();
}
Cells::ValueT::const_iterator Cells::cbegin() const
{
return data.cbegin();
}
Cells::ValueT::const_iterator Cells::cend() const
{
return data.cend();
}
SValue* Cells::operator[]( std::size_t index )
{
return data[ index ].get();
}
const SValue* Cells::operator[]( std::size_t index ) const
{
return data[ index ].get();
}
bool Cells::operator==( const Cells& other ) const
{
return std::equal(
data.cbegin(), data.cend(), other.cbegin(), other.cend(), []( const auto& left, const auto& right ) {
return *left == *right;
} );
}