SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
SpecsKeyIntervals.cc
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
10 
11 
12 namespace SWC { namespace DB { namespace Specs {
13 
14 
16 
17 
19  : Vec(other) {
20 }
21 
23 
24 void KeyIntervals::copy(const KeyIntervals& other) {
25  Vec::operator=(other);
26 }
27 
29  return emplace_back();
30 }
31 
33  return emplace_back(other);
34 }
35 
37  return emplace_back(std::move(other));
38 }
39 
40 KeyInterval& KeyIntervals::add(const Key& start, const Key& finish) {
41  return emplace_back(start, finish);
42 }
43 
44 KeyInterval& KeyIntervals::add(Key&& start, Key&& finish) {
45  return emplace_back(std::move(start), std::move(finish));
46 }
47 
48 bool KeyIntervals::equal(const KeyIntervals& other) const noexcept {
49  if(size() == other.size()) {
50  auto it = cbegin();
51  for(auto it2 = other.cbegin(); it != cend(); ++it, ++it2)
52  if(!it->start.equal(it2->start) ||
53  !it->finish.equal(it2->finish))
54  return false;
55  }
56  return true;
57 }
58 
59 void KeyIntervals::print(std::ostream& out) const {
60  out << "KeyIntervals(";
61  if(!empty()) {
62  out << "size=" << size();
63  for(const auto& key : *this) {
64  key.start.print(out << " [Start");
65  key.finish.print(out << " Finish");
66  out << ']';
67  }
68  }
69  out << ')';
70 }
71 
72 void KeyIntervals::display(std::ostream& out, bool pretty,
73  const std::string& offset) const {
74  out << offset << "KeyIntervals([\n";
75  for(const auto& key : *this) {
76  out << offset << " Key(\n"
77  << offset << " start(";
78  key.start.display(out, pretty);
79  out << ")\n"
80  << offset << " finish(";
81  key.finish.display(out, pretty);
82  out << ")\n";
83  out << offset << " )\n";
84  }
85  out << offset << "])\n";
86 }
87 
88 
89 }}}
SpecsKeyIntervals.h
SWC::DB::Specs::KeyIntervals
Definition: SpecsKeyIntervals.h:94
SWC::Core::Vector< KeyInterval >::operator=
SWC_CAN_INLINE Vector & operator=(Vector &&other) noexcept
Definition: Vector.h:141
SWC::DB::Specs::KeyInterval
Definition: SpecsKeyIntervals.h:18
SWC::DB::Specs::KeyInterval::~KeyInterval
~KeyInterval() noexcept
Definition: SpecsKeyIntervals.cc:15
SWC::DB::Specs::Key
Definition: SpecsKey.h:136
SWC::DB::Specs::KeyIntervals::copy
void copy(const KeyIntervals &other)
Definition: SpecsKeyIntervals.cc:24
SWC::DB::Specs::KeyIntervals::equal
bool SWC_PURE_FUNC equal(const KeyIntervals &other) const noexcept
Definition: SpecsKeyIntervals.cc:48
SWC::Core::Vector< KeyInterval >::empty
constexpr SWC_CAN_INLINE bool empty() const noexcept
Definition: Vector.h:168
SWC::DB::Specs::KeyIntervals::KeyIntervals
SWC_CAN_INLINE KeyIntervals() noexcept
Definition: SpecsKeyIntervals.h:102
SWC::DB::Specs::KeyIntervals::add
KeyInterval & add()
Definition: SpecsKeyIntervals.cc:28
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
size
uint32_t size
Buffer size.
Definition: HeaderBufferInfo.h:47
Serialization.h
SWC::Core::Vector< KeyInterval >
SWC::DB::Specs::KeyIntervals::display
void display(std::ostream &out, bool pretty, const std::string &offset) const
Definition: SpecsKeyIntervals.cc:72
SWC::DB::Specs::KeyIntervals::~KeyIntervals
~KeyIntervals() noexcept
Definition: SpecsKeyIntervals.cc:22
SWC::DB::Specs::KeyIntervals::print
void print(std::ostream &out) const
Definition: SpecsKeyIntervals.cc:59
KeyComparator.h
SWC::Core::Vector< KeyInterval >::size
constexpr SWC_CAN_INLINE size_type size() const noexcept
Definition: Vector.h:189
SWC::Core::Vector< KeyInterval >::emplace_back
SWC_CAN_INLINE reference emplace_back(ArgsT &&... args)
Definition: Vector.h:349