Skip to content

Commit

Permalink
work on documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Feb 9, 2024
1 parent ff6d35c commit 97bafad
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 144 deletions.
114 changes: 76 additions & 38 deletions include/flatmemory/details/containers/vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,18 @@ class VariableSizedTypeVector
VariableSizedTypeVector(VariableSizedTypeVector&& other) = default;
VariableSizedTypeVector& operator=(VariableSizedTypeVector&& other) = default;

[[nodiscard]] constexpr size_t empty() const {
return m_data.empty();
}
/**
* Element access
*/

[[nodiscard]] constexpr size_t size() const {
return m_data.size();
[[nodiscard]] View<T> operator[](size_t pos) {
assert(pos <= static_cast<int>(size()));
return m_data[pos];
}

void push_back(const Builder<T>& builder) {
m_data.push_back(View<T>(m_storage.write(builder.buffer().data(), builder.buffer().size())));
[[nodiscard]] ConstView<T> operator[](size_t pos) const {
assert(pos <= static_cast<int>(size()));
return m_data[pos];
}

[[nodiscard]] View<T> back() {
Expand All @@ -60,20 +62,37 @@ class VariableSizedTypeVector
return m_data.back();
}

[[nodiscard]] View<T> operator[](size_t pos) {
assert(pos <= static_cast<int>(size()));
return m_data[pos];
}

[[nodiscard]] ConstView<T> operator[](size_t pos) const {
assert(pos <= static_cast<int>(size()));
return m_data[pos];
}
/**
* Iterators
*/

[[nodiscard]] auto begin() { return m_data.begin(); }
[[nodiscard]] const auto begin() const { return m_data.begin(); }
[[nodiscard]] auto end() { return m_data.end(); }
[[nodiscard]] const auto end() const { return m_data.end(); }


/**
* Capacity
*/

[[nodiscard]] constexpr size_t empty() const {
return m_data.empty();
}

[[nodiscard]] constexpr size_t size() const {
return m_data.size();
}


/**
* Modifiers
*/

void push_back(const Builder<T>& builder) {
m_data.push_back(View<T>(m_storage.write(builder.buffer().data(), builder.buffer().size())));
}
};

/**
Expand Down Expand Up @@ -102,16 +121,22 @@ class FixedSizedTypeVector
FixedSizedTypeVector(FixedSizedTypeVector&& other) = default;
FixedSizedTypeVector& operator=(FixedSizedTypeVector&& other) = default;

[[nodiscard]] constexpr size_t empty() const {
return m_data.empty();
}

[[nodiscard]] constexpr size_t size() const {
return m_data.size();
/**
* Element access
*/

[[nodiscard]] View<T> operator[](size_t pos) {
if (pos >= size()) {
resize(pos);
}
return m_data[pos];
}

void push_back(const Builder<T>& builder) {
m_data.push_back(View<T>(m_storage.write(builder.get_data(), builder.size())));
[[nodiscard]] ConstView<T> operator[](size_t pos) const {
if (pos >= size()) {
resize(pos);
}
return m_data[pos];
}

[[nodiscard]] View<T> back() {
Expand All @@ -122,18 +147,36 @@ class FixedSizedTypeVector
return m_data.back();
}

[[nodiscard]] View<T> operator[](size_t pos) {
if (pos >= size()) {
resize(pos);
}
return m_data[pos];

/**
* Iterators
*/

[[nodiscard]] auto begin() { return m_data.begin(); }
[[nodiscard]] const auto begin() const { return m_data.begin(); }
[[nodiscard]] auto end() { return m_data.end(); }
[[nodiscard]] const auto end() const { return m_data.end(); }


/**
* Capacity
*/

[[nodiscard]] constexpr size_t empty() const {
return m_data.empty();
}

[[nodiscard]] ConstView<T> operator[](size_t pos) const {
if (pos >= size()) {
resize(pos);
}
return m_data[pos];
[[nodiscard]] constexpr size_t size() const {
return m_data.size();
}


/**
* Modifiers
*/

void push_back(const Builder<T>& builder) {
m_data.push_back(View<T>(m_storage.write(builder.get_data(), builder.size())));
}

void resize(size_t count) {
Expand All @@ -144,11 +187,6 @@ class FixedSizedTypeVector
m_data.push_back(View<T>(written_data));
}
}

[[nodiscard]] auto begin() { return m_data.begin(); }
[[nodiscard]] const auto begin() const { return m_data.begin(); }
[[nodiscard]] auto end() { return m_data.end(); }
[[nodiscard]] const auto end() const { return m_data.end(); }
};


Expand Down
6 changes: 4 additions & 2 deletions include/flatmemory/details/types/bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
namespace flatmemory
{
/**
* Dispatcher for tuple.
* Dispatcher for Bitset.
*/
template<typename Block>
struct Bitset : public Custom {
Bitset(const Bitset& other) {} // Non-trivial copy-constructor
/// @brief Non-trivial copy-constructor
/// @param other
Bitset(const Bitset& other) {}
};


Expand Down
6 changes: 4 additions & 2 deletions include/flatmemory/details/types/trivial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
namespace flatmemory
{
/**
* Dispatcher for tuple.
* Dispatcher for Trivial.
*/
template<IsTriviallyCopyable T>
struct Trivial : public Custom {
Trivial(const Trivial& other) {} // Non-trivial copy-constructor
/// @brief Non-trivial copy-constructor
/// @param other
Trivial(const Trivial& other) {}
};


Expand Down
6 changes: 4 additions & 2 deletions include/flatmemory/details/types/tuple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
namespace flatmemory
{
/**
* Dispatcher for tuple.
* Dispatcher for Tuple.
*/
template<IsTriviallyCopyableOrCustom... Ts>
struct Tuple : public Custom {
Tuple(const Tuple& other) {} // Non-trivial copy-constructor
/// @brief Non-trivial copy-constructor
/// @param other
Tuple(const Tuple& other) {}
};


Expand Down
Loading

0 comments on commit 97bafad

Please sign in to comment.