diff --git a/archive/box-README.md b/archive/box-README.md deleted file mode 100644 index d64253c..0000000 --- a/archive/box-README.md +++ /dev/null @@ -1,526 +0,0 @@ -# Cortex : { box } - -[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md) -[![License](https://img.shields.io/github/license/cortexlib/box)](LICENSE) -![Current Release](https://img.shields.io/github/v/release/cortexlib/box) -![DDS Version](https://img.shields.io/badge/DDS%20Version-alpha--6-blue) -![C++ Standard](https://img.shields.io/badge/C%2B%2B%20Standard-C%2B%2B20-red) -![GCC](https://img.shields.io/badge/GCC-11.1.0-yellow) -![Clang](https://img.shields.io/badge/Clang-❌-yellow) - -Box is a two dimensional generic container. It aims to provide expressive and dynamic operations that allow for easy fast mainpulation of the data's shape. Box is available under the `cxl::` namespace. - -Box has been built and tested for C++20 only. This is because `box` relies on `std::ranges`. -Box also only works with GCC-11 currently due to Clang not having completed [PR0634R3](https://wg21.link/P0634R3) yet which invalidates part of the `std::ranges` library. - -Box is built and packaged using the [BPT/DDS](https://github.com/vector-of-bool/dds) building tool. Click [here](https://dds.pizza) view the documentation and install instructions for BPT/DDS. BPT/DDS is a command line tool for managing dependencies and building applications in C++. - -Box is part of a larger library called the [Cortex Library](https://github.com/cortexlib/cortexlib). You can include box independently in your project and only install box's dependencies or you can add the larger Cortex Library. Instructions are [here] (<- add link). - ---- - -## Contents - -- [Cortex : { box }](#cortex---box-) - - [Contents](#contents) - - [Features](#features) - - [Adding Box to your BPT/DDS Project](#adding-box-to-your-bptdds-project) - - [Examples](#examples) - - [Operators](#operators) - - [Mapping](#mapping) - - [Row and Column Iterators](#row-and-column-iterators) - - [Restructuring](#restructuring) - - [Resize](#resize) - - [Reshape](#reshape) - - [Flips](#flips) - - [Rotates](#rotates) - - [Contributing and License](#contributing-and-license) - - [Links and Resources](#links-and-resources) - ---- - -## Features - -- STL complient and valid begin and end iterators. -- Row and Column iterators allowing traversal and manipulation of discrete parts of the box. -- Works with range-for loops, STL algorithms and C++20's `std::ranges`. -- Scalar and Box comparison operators. -- Builtin function mapping and mapping operator overload. -- Common arithmatic and bitwise transformation methods. -- Operator overloads for arithmatic and bitwise transformations for expressive notation. -- Restructuring methods that can change the data's structure. -- Custom allocator support similar to the STL generic containers. - ---- - -## Adding Box to your BPT/DDS Project - -To add Box to your project is super simple. The first thing you need to do is add the repository that hosts the package. Box along with all of the cortexlib can be found on the [Trove Package Index](https://trovepi.dev). To add, simply run: - -```sh -dds pkg repo add "https://trovepi.dev" -``` - -This will allow BPT/DDS to find the packages host by Trove. Once you've added the repo, go to your package.json5 file within your pojects directory and add box as a dependency. - -```json5 -{ - name: 'package', - version: 'x.x.x', - namespace: 'namespace', - test_driver: 'Catch-Main', - depends: [ - 'cortex-box^1.0.0' - ] -} -``` - -Finally, any library that uses Box needs to declare that it is in use. This is done in the library.json5 files corresponding to the indiviual libraries. More information on BPT/DDS package structures and libraries can be found [here](https://dds.pizza/docs/guide/packages.html). - -```json5 -{ - name: 'library', - uses: [ - 'cortex/box' - ] -} -``` - -And you all set. On the next build run, BPT/DDS with install box and build against it. - ---- - -## Examples - -### Operators - -Box has many operator overloads so that you can express common arithmatic, bitwise and restructuring operations with a simple notation. Check out the [docs](docs) for the full list. - -```cpp -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - /// Uses row iterators to traverse elements. - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - /// Transposes box, multiplies by 3 and bit_or's every element against 4. - auto new_box { !bx * 3 | 4 }; - - print(new_box); - - /// Output: - /// { 7 12 21 } - /// { 6 15 28 } - /// { 13 22 31 } - - return 0; -} -``` - -If you prefer, each operator has a corresponding method within the box, allowing for a method chaining notation instead. - -```cpp -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - auto new_box { bx.transpose().mul(3).bit_or(4) }; - - print(new_box); - - /// Output: - /// { 7 12 21 } - /// { 6 15 28 } - /// { 13 22 31 } - - return 0; -} -``` - -### Mapping - -While box has iterators that are complient with the standard library's algorithms and the `std::ranges` library, box also has a convienent notation for mapping functions over a box. Mappings can be chained aswell. - -```cpp -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto square = [](auto x){ return x * x; }; -auto xor_3 = [](auto x){ return x ^ 3; }; - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - /// box.map(square) could also be used. - auto new_box = bx || square; - - print(new_box); - - /// Output: - /// { 1 4 9 } - /// { 16 25 36 } - /// { 49 64 81 } - - auto other_box = new_box || square - || xor_3; - - print(other_box); - - /// Output: - /// { 2 19 82 } - /// { 259 626 1299 } - /// { 2402 4099 6562 } - - return 0; -} -``` - -box::map is also overloaded to take other ranges or iterator pairs to map with the box. - -```cpp -#include -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto add = [](auto x, auto v){ return x + v; }; - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - std::vector v { 3, 5, 13, 1, 12, 68, 34, 4, 76 }; - - - auto new_box = bx.map(v, add); - - print(new_box); - - /// Output: - /// { 4 7 16 } - /// { 5 17 74 } - /// { 41 12 85 } - - return 0; -} -``` - -### Row and Column Iterators - -Box has to unique iterators, the row and column iterators. These iterators traverse a size field allowing them to jump discretely between rows or columns. - -```cpp -#include -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - /// Only negates elements in the middle (1st) column. - std::transform(bx.column_begin(1), bx.column_end(1), bx.column_begin(1), std::negate{}); - - print(bx); - - /// Output: - /// { 1 -2 3 } - /// { 4 -5 6 } - /// { 7 -8 9 } - - return 0; -} -``` - -### Restructuring - -Box sits between `std::vector` and `std::array` in terms of resource managment. The elements are stored dynamically but individual elements cannot be added to the box. However, a box is not fixed to its given size at construction. Box supportst two operations for changing the dimensions of the box. - -Box also supports more literal transformations of the data it holds. You've already seen one, `box::transpose` (!) which performs the mathematical transpose. There are two other categories for transformations, flips and rotates. - -#### Resize - -Resizing allows the box's recources to potentially be reallocated if the new dimensions exceed the the old dimensions. - -```cpp -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - print(bx); - - /// Output: - /// { 1 2 3 } - /// { 4 5 6 } - /// { 7 8 9 } - - bx.resize(4, 3); - - print(bx); - - /// Output: - /// { 1 2 3 } - /// { 4 5 6 } - /// { 7 8 9 } - /// { 0 0 0 } - - return 0; -} -``` - -#### Reshape - -If you wish to change the dimensions of the box but its overall size remains the same, you can use the reshape method. This will alter the dimension of the box and how the data is viewed but but garuntees that resources wont be reallocated. Be warned that an exception will be thrown if the reshape fails. - -```cpp -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } - , { 10, 11, 12 } }; - - print(bx); - - /// Output: - /// { 1 2 3 } - /// { 4 5 6 } - /// { 7 8 9 } - /// { 10, 11, 12 } - - bx.reshape(6, 2); - - print(bx); - - /// Output: - /// { 0 0 } - /// { 0 0 } - /// { 0 0 } - /// { 0 0 } - /// { 0 0 } - /// { 0 0 } - - return 0; -} -``` - -#### Flips - -Flips allow you to change the orientation of the data. Two flip methods exist as part of the box API; `box::vflip` which inverts the elements vertically and `box::hflip` which inverts the elements horizontlly. - -```cpp -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - print(bx); - - /// Output: - /// { 1 2 3 } - /// { 4 5 6 } - /// { 7 8 9 } - - auto new_box { bx.vflip().hflip() }; - - print(new_box); - - /// Output: - /// { 9 8 7 } - /// { 6 5 4 } - /// { 3 2 1 } - - return 0; -} -``` - -#### Rotates - -Rotates are the other form of data manipulation methods. Two rotates exist, `box::rrotate` which rotates the box 90 degrees to the left and `box::lrotate` which rotate the box 90 degrees to the right. - -```cpp -#include -#include - -template -void print(const cxl::box& bx) -{ - for (auto ridx { 0uL }; ridx < bx.rows(); ++ridx) - { - std::cout << "{ "; - for (auto elem { bx.row_begin(ridx) }; elem != bx.row_end(ridx); ++elem) - std::cout << *elem << ' '; - std::cout << "}\n"; - } -} - -auto main() -> int -{ - cxl::box bx { { 1, 2, 3 } - , { 4, 5, 6 } - , { 7, 8, 9 } }; - - print(bx); - - /// Output: - /// { 1 2 3 } - /// { 4 5 6 } - /// { 7 8 9 } - - print(bx.rrotate()); - - /// Output: - /// { 7 4 1 } - /// { 8 5 2 } - /// { 9 6 3 } - - print(bx.lrotate()); - - /// Output: - /// { 3 6 9 } - /// { 2 5 8 } - /// { 1 4 7 } - - return 0; -} -``` - ---- - -## Contributing and License - -- Refer to [CONTRIBUTING.md](./CONTRIBUTING.md) for ways to contribute and support the development of `cxl::box`. - -- Box is under the MIT License. Refer to [LICENSE](./LICENSE) for full details. - ---- - -## Links and Resources - -- [DDS](https://dds.pizza) -- [DDS Install Guide](https://dds.pizza/docs/tut/install.html) -- [Trove Package Index Homepage](https://trovepi.dev) -- [Cortex Library](https://github.com/cortexlib/cortexlib) diff --git a/archive/enumerate.hpp b/archive/enumerate.hpp deleted file mode 100644 index 1c273e7..0000000 --- a/archive/enumerate.hpp +++ /dev/null @@ -1,149 +0,0 @@ -/// -*- C++ -*- Header compatibility - -/// \brief An adaptor for creating an iterator -/// and index pair in a for loop. -/// -/// Author: Tyler Swann (oraqlle@github.com) -/// -/// Header Version: v1.0.0 -/// -/// Date: 25-06-2022 -/// -/// License: MIT -/// -/// Copyright: Copyright (c) 2022 -/// \file enumerate.hpp - -#ifndef CORTEX_ENUMERATE_H -# define CORTEX_ENUMERATE_H 1 - -#include - -# if __cplusplus >= 201703L - -namespace cortex -{ - /// \brief Moves a container to the iterable_wrapper object. - /// - /// \tparam _Tp - /// \tparam _Iterator - /// \tparam _Iterator, - /// \param __iterable - /// \param __offset - /// \return structured binding of the containers elements and an interger offset. - template())), - typename = decltype(std::end(std::declval<_Tp>()))> - constexpr auto enumerate(_Tp& __iterable, int __start = 0, int __step = 1) - { - - - /// \brief iterator wrapper for the iterable container. - struct iterator - { - int m_index; - int m_step; - _Iterator m_iterator; - - - /// \brief operator!= overload for checking if an iterator is equal to another - /// containers iterator. - /// - /// \param other - /// \return true - /// \return false - bool operator!= (const iterator& other) const { return m_iterator != other.m_iterator; } - - - - /// \brief Invokes iterator objects operator++ and - /// increments the index. - void operator++ () { m_index += m_step; ++m_iterator; } - - - - /// \brief Ties the index and the iterator together in a structured binding. - /// - /// \return structured binding [item, elem]. - auto operator* () const { return std::tie(m_index, *m_iterator); } - }; // struct iterator - - - - /// \brief A wrapper for a iterable container and its index offset. - struct iterable_wrapper - { - _Tp m_iterable; - int m_offset; - int m_step; - - - /// \brief Returns an iterator object to the first element of the container. - /// - /// \return auto - auto begin() { return iterator{ static_cast(m_offset), static_cast(m_step), std::begin(m_iterable) }; } - - - - /// \brief Returns an iterator object of one past the last element of the container. - /// - /// \return auto - auto end() { return iterator{ static_cast(m_offset), static_cast(m_step), std::end(m_iterable) }; } - }; // struct iterable_wrapper - - - /// \returns iterable_wrapper object with the container object and offset value - /// forwarded to wrapper. - return iterable_wrapper{ std::forward<_Tp>(__iterable), std::forward(__start), std::forward(__step) }; - } - - - - namespace adaptors - { - - - /// \brief proxy for adapting an index to an container. - /// - /// \tparam _Tp - template - struct enumerate_proxy - { - _Tp m_start; - _Up m_step; - }; - - - - /// \brief - /// - /// \tparam _Tp - /// \param __offset - /// \return index proxy object with the offset value. - template - auto enumerate(_Tp __offset = 0) { return enumerate_proxy<_Tp, _Tp>{__offset, static_cast<_Tp>(1)}; } - - - template - auto enumerate(_Tp __offset, _Up __step) { return enumerate_proxy<_Tp, _Up>{__offset, __step}; } - - - /// \brief operator| overload for piping the index_proxy object returnd - /// by indexed to the enumerate function. - /// - /// \tparam _Container - /// \tparam _Tp - /// \param __container - /// \param __proxy - /// \return constexpr auto - template - constexpr auto operator| (const _Container& __container, const enumerate_proxy<_Tp, _Up>& __proxy) - { return cxl::enumerate(__container, __proxy.m_start, __proxy.m_step); } - - } // namespace adaptors - -} // namespace cortex - -# endif // __cplusplus >= 201703L - -#endif // CORTEX_ENUMERATE_H \ No newline at end of file diff --git a/archive/iter-tests/column.create.test.cpp b/archive/iter-tests/column.create.test.cpp deleted file mode 100644 index 0a91391..0000000 --- a/archive/iter-tests/column.create.test.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include - -TEST_CASE("Creating column_iterators") -{ - SECTION("Default Constructor") - { - cxl::column_iterator::iterator> it; - REQUIRE(it.base() == std::vector::iterator()); - REQUIRE(it.rows() == 0uL); - REQUIRE(it.columns() == 0uL); - REQUIRE(it.row_index() == 0uL); - REQUIRE(it.column_index() == 0uL); - } - - SECTION("Value Constructor") - { - std::vector v = { 0, 1 - , 2, 3 - , 4, 5 - , 6, 7 - , 8, 9 }; - - auto it { cxl::column_iterator::iterator>(v.begin(), 0ul, 0ul, 5ul, 2ul) }; - - REQUIRE(it.base() == v.begin()); - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - REQUIRE(it.row_index() == 0ul); - REQUIRE(it.column_index() == 0ul); - - /// First Column -------------------------------- - - REQUIRE(*it == 0); - REQUIRE(it.base() == v.begin()); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 0ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 2); - REQUIRE(it.base() == v.begin() + 2); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 1ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 4); - REQUIRE(it.base() == v.begin() + 4); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 2ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 6); - REQUIRE(it.base() == v.begin() + 6); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 3ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 8); - REQUIRE(it.base() == v.begin() + 8); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 4ul); - REQUIRE(it.column_index() == 0ul); - - /// Second Column -------------------------------- - - ++it; - REQUIRE(*it == 1); - REQUIRE(it.base() == v.begin() + 1); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 0ul); - REQUIRE(it.column_index() == 1ul); - - ++it; - REQUIRE(*it == 3); - REQUIRE(it.base() == v.begin() + 3); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 1ul); - REQUIRE(it.column_index() == 1ul); - - ++it; - REQUIRE(*it == 5); - REQUIRE(it.base() == v.begin() + 5); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 2ul); - REQUIRE(it.column_index() == 1ul); - - ++it; - REQUIRE(*it == 7); - REQUIRE(it.base() == v.begin() + 7); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 3ul); - REQUIRE(it.column_index() == 1ul); - - ++it; - REQUIRE(*it == 9); - REQUIRE(it.base() == v.begin() + 9); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 4ul); - REQUIRE(it.column_index() == 1ul); - } -} \ No newline at end of file diff --git a/archive/iter-tests/column.operators.test.cpp b/archive/iter-tests/column.operators.test.cpp deleted file mode 100644 index 3519475..0000000 --- a/archive/iter-tests/column.operators.test.cpp +++ /dev/null @@ -1,123 +0,0 @@ -#include -#include -#include -#include - -struct Point -{ - int x; - int y; -}; - -TEST_CASE("column_iterator operators") -{ - std::vector v { 0, 1, 2 - , 3, 4, 5 - , 6, 7, 8 }; - - auto it { cxl::column_iterator::iterator>(v.begin(), 0ul, 0ul, 3ul, 3ul) }; - - SECTION("operator* [dereference]") - { REQUIRE(*it == 0); } - - std::vector points { { 1, 5 } }; - - auto indirect_it { cxl::column_iterator::iterator>(points.begin(), 0ul, 0ul, 1ul, 1ul) }; - - SECTION("operator-> [indirection]") - { REQUIRE(indirect_it->x == 1); } - - SECTION("operator-> [indirection]") - { REQUIRE(indirect_it->y == 5); } - - SECTION("operator++") - { REQUIRE(*++it == 3);} - - SECTION("operator++(int)") - { - REQUIRE(*it++ == 0); - REQUIRE(*it == 3); - } - - SECTION("operator--") - { - it = cxl::column_iterator::iterator>(v.begin() + 8, 2ul, 2ul, 3ul, 3ul); - REQUIRE(*it == 8); - REQUIRE(*--it == 5); - } - - SECTION("operator--(int)") - { - it = cxl::column_iterator::iterator>(v.begin() + 5, 1ul, 2ul, 3ul, 3ul); - REQUIRE(*it-- == 5); - REQUIRE(*it == 2); - } - - // SECTION("operator[]") - // { - // REQUIRE(it[0] == 0); - // REQUIRE(it[1] == 3); - // REQUIRE(it[2] == 1); - // REQUIRE(it[3] == 4); - // REQUIRE(it[4] == 2); - // REQUIRE(it[5] == 5); - // } - - // SECTION("operator+") - // { REQUIRE(*(it + 2) == 1); } - - // SECTION("operator+=") - // { - // it += 5; - // REQUIRE(*it == 5); - // } - - // SECTION("operator-") - // { - // it += 4; - // REQUIRE(*(it - 3) == 3); - // } - - // SECTION("operator-=") - // { - // it += 4; - // it -= 2; - // REQUIRE(*it == 1); - // } -} - -TEST_CASE("Comparison") -{ - std::vector v { 0, 1, 2 - , 3, 4, 5 - , 6, 7, 8 }; - - auto it { cxl::column_iterator::iterator>(v.begin(), 0ul, 0ul, 3ul, 3ul) }; - auto it2 { cxl::column_iterator::iterator>(it) }; - auto it3 { cxl::column_iterator::iterator>(v.begin() + 7, 2ul, 1ul, 3ul, 3ul) }; - auto it4 { cxl::column_iterator::iterator>(v.begin() + 2, 0ul, 2ul, 3ul, 3ul) }; - - SECTION("operator ==") - { REQUIRE(it == it2); } - - SECTION("operator !=") - { REQUIRE(it != it3); } - - SECTION("operator <") - { REQUIRE(it < it4); } - - SECTION("operator <=") - { - REQUIRE(it <= it2); - REQUIRE(it <= it4); - } - - SECTION("operator >") - { REQUIRE(it4 > it3); } - - SECTION("operator >=") - { - REQUIRE(it4 >= it3); - REQUIRE(it4 >= ++it3); - } -} \ No newline at end of file diff --git a/archive/iter-tests/enumerate.test.cpp b/archive/iter-tests/enumerate.test.cpp deleted file mode 100644 index bbbd226..0000000 --- a/archive/iter-tests/enumerate.test.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include - -TEST_CASE("Basic Enumeration") -{ - std::vector v = {1, 2, 3, 4, 5}; - - for (auto [i, e] : v | cxl::adaptors::enumerate(0)) - { - REQUIRE(e == v[std::size_t(i)]); - } -} - -TEST_CASE("Enumeration from negative index") -{ - std::vector v = {1, 2, 3, 4, 5}; - - auto check {-2}; - - for (auto [i, e] : v | cxl::adaptors::enumerate(-1)) - { - REQUIRE(i == ++check); - } -} - - -TEST_CASE("Enumeration upwards with non-one step") -{ - std::vector v = {1, 2, 3, 4, 5}; - - auto check {0}; - - for (auto [i, e] : v | cxl::adaptors::enumerate(0, 2)) - { - REQUIRE(i == check); - check += 2; - } -} - - -TEST_CASE("Enumeration downwards with non-one step") -{ - std::vector v = {1, 2, 3, 4, 5}; - - auto check {static_cast(v.size())}; - - for (auto [i, e] : v | cxl::adaptors::enumerate(static_cast(v.size() - 1), -1)) - REQUIRE(i == --check); -} - -using namespace cxl::adaptors; - -TEST_CASE("Eliding the Adaptor Namespace") -{ - std::vector v = {1, 2, 3, 4, 5}; - - for (auto [i, e] : v | enumerate(0)) - { - REQUIRE(e == v[std::size_t(i)]); - } -} \ No newline at end of file diff --git a/archive/iter-tests/row.create.test.cpp b/archive/iter-tests/row.create.test.cpp deleted file mode 100644 index 8e3720f..0000000 --- a/archive/iter-tests/row.create.test.cpp +++ /dev/null @@ -1,142 +0,0 @@ -#include -#include -#include - -TEST_CASE("Creating row_iterators") -{ - SECTION("Default Constructor") - { - cxl::row_iterator::iterator> it; - REQUIRE(it.base() == std::vector::iterator()); - REQUIRE(it.rows() == 0uL); - REQUIRE(it.columns() == 0uL); - REQUIRE(it.row_index() == 0uL); - REQUIRE(it.column_index() == 0uL); - } - - SECTION("Value Constructor") - { - std::vector v = { 0, 1 - , 2, 3 - , 4, 5 - , 6, 7 - , 8, 9 }; - - auto it { cxl::row_iterator::iterator>(v.begin(), 0ul, 0ul, 5ul, 2ul) }; - - REQUIRE(it.base() == v.begin()); - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - REQUIRE(it.row_index() == 0ul); - REQUIRE(it.column_index() == 0ul); - - /// First Row -------------------------------- - - REQUIRE(*it == 0); - REQUIRE(it.base() == v.begin()); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 0ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 1); - REQUIRE(it.base() == v.begin() + 1); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 0ul); - REQUIRE(it.column_index() == 1ul); - - /// Second Row -------------------------------- - - ++it; - REQUIRE(*it == 2); - REQUIRE(it.base() == v.begin() + 2); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 1ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 3); - REQUIRE(it.base() == v.begin() + 3); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 1ul); - REQUIRE(it.column_index() == 1ul); - - /// Third Row -------------------------------- - - ++it; - REQUIRE(*it == 4); - REQUIRE(it.base() == v.begin() + 4); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 2ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 5); - REQUIRE(it.base() == v.begin() + 5); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 2ul); - REQUIRE(it.column_index() == 1ul); - - /// Fourth Row -------------------------------- - - ++it; - REQUIRE(*it == 6); - REQUIRE(it.base() == v.begin() + 6); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 3ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 7); - REQUIRE(it.base() == v.begin() + 7); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 3ul); - REQUIRE(it.column_index() == 1ul); - - /// Fifth Row -------------------------------- - - ++it; - REQUIRE(*it == 8); - REQUIRE(it.base() == v.begin() + 8); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 4ul); - REQUIRE(it.column_index() == 0ul); - - ++it; - REQUIRE(*it == 9); - REQUIRE(it.base() == v.begin() + 9); - - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - - REQUIRE(it.row_index() == 4ul); - REQUIRE(it.column_index() == 1ul); - } -} \ No newline at end of file diff --git a/archive/iter-tests/row.operators.test.cpp b/archive/iter-tests/row.operators.test.cpp deleted file mode 100644 index 5d71c8d..0000000 --- a/archive/iter-tests/row.operators.test.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include - -struct Point -{ - int x; - int y; -}; - -TEST_CASE("row_iterator - Movement") -{ - std::vector v { 0, 1, 2 - , 3, 4, 5 - , 6, 7, 8 }; - - auto it { cxl::row_iterator::iterator>(v.begin(), 0ul, 0ul, 3ul, 3ul) }; - - SECTION("operator*(dereference)") - { REQUIRE(*it == 0); } - - std::vector points { { 1, 5 } }; - - auto indirect_it { cxl::row_iterator::iterator>(points.begin(), 0ul, 0ul, 1ul, 1ul) }; - - SECTION("operator-> [indirection]") - { REQUIRE(indirect_it->x == 1); } - - SECTION("operator-> [indirection]") - { REQUIRE(indirect_it->y == 5); } - - SECTION("operator++") - { REQUIRE(*++it == 1);} - - SECTION("operator++(int)") - { - REQUIRE(*it++ == 0); - REQUIRE(*it == 1); - } - - SECTION("operator--") - { - it = cxl::row_iterator::iterator>(v.begin() + 8, 2ul, 2ul, 3ul, 3ul); - REQUIRE(*it == 8); - REQUIRE(*--it == 7); - } - - SECTION("operator--(int)") - { - it = cxl::row_iterator::iterator>(v.begin() + 5, 1ul, 2ul, 3ul, 3ul); - REQUIRE(*it-- == 5); - REQUIRE(*it == 4); - } - - // SECTION("operator[]") - // { - // REQUIRE(it[0] == 0); - // REQUIRE(it[1] == 1); - // REQUIRE(it[2] == 2); - // REQUIRE(it[3] == 3); - // REQUIRE(it[4] == 4); - // REQUIRE(it[5] == 5); - // } - - // SECTION("operator+") - // { REQUIRE(*(it + 2) == 1); } - - // SECTION("operator+=") - // { - // it += 5; - // REQUIRE(*it == 5); - // } - - // SECTION("operator-") - // { - // it += 4; - // REQUIRE(*(it - 3) == 3); - // } - - // SECTION("operator-=") - // { - // it += 4; - // it -= 2; - // REQUIRE(*it == 1); - // } -} - -TEST_CASE("Comparison") -{ - std::vector v { 0, 1, 2 - , 3, 4, 5 - , 6, 7, 8 }; - - auto it { cxl::row_iterator::iterator>(v.begin(), 0ul, 0ul, 3ul, 3ul) }; - auto it2 { cxl::row_iterator::iterator>(it) }; - auto it3 { cxl::row_iterator::iterator>(v.begin() + 4, 1ul, 1ul, 3ul, 3ul) }; - auto it4 { cxl::row_iterator::iterator>(v.begin() + 5, 1ul, 2ul, 3ul, 3ul) }; - - SECTION("operator ==") - { REQUIRE(it == it2); } - - SECTION("operator !=") - { REQUIRE(it != it3); } - - SECTION("operator <") - { REQUIRE(it < it4); } - - SECTION("operator <=") - { - REQUIRE(it <= it2); - REQUIRE(it <= it4); - } - - SECTION("operator >") - { REQUIRE(it4 > it3); } - - SECTION("operator >=") - { - REQUIRE(it4 >= it3); - REQUIRE(it4 >= ++it3); - } -} \ No newline at end of file diff --git a/archive/iter-tests/two_dim.compare.test.cpp b/archive/iter-tests/two_dim.compare.test.cpp deleted file mode 100644 index 53c7c2f..0000000 --- a/archive/iter-tests/two_dim.compare.test.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include -#include - -TEST_CASE("Comparisons") -{ - std::vector v { 0, 1, 2 - , 3, 4, 5 - , 6, 7, 8 }; - - auto it = cxl::two_dim_iterator::iterator>(v.begin(), 0ul, 0ul, 3ul, 3ul); - - SECTION("Equality") - { REQUIRE(it == cxl::two_dim_iterator::iterator>(v.begin(), 0ul, 0ul, 3ul, 3ul)); } - - SECTION("Inequality") - { REQUIRE(it != cxl::two_dim_iterator::iterator>(v.begin() + 8, 2ul, 2ul, 3ul, 3ul)); } - - SECTION("Less than") - { REQUIRE(it < cxl::two_dim_iterator::iterator>(v.begin() + 8, 2ul, 2ul, 3ul, 3ul)); } - - SECTION("Greater than") - { REQUIRE(cxl::two_dim_iterator::iterator>(v.begin() + 8, 2ul, 2ul, 3ul, 3ul) > it); } - - SECTION("Less than or equal") - { REQUIRE(it <= cxl::two_dim_iterator::iterator>(v.begin() + 8, 2ul, 2ul, 3ul, 3ul)); } - - SECTION("Greater than or equal") - { REQUIRE(cxl::two_dim_iterator::iterator>(v.begin() + 8, 2ul, 2ul, 3ul, 3ul) >= it); } - - SECTION("Spaceship") - { - REQUIRE(it <=> cxl::two_dim_iterator::iterator>(v.begin(), 2ul, 2ul, 3ul, 3ul) == std::strong_ordering::equal); - REQUIRE(it <=> cxl::two_dim_iterator::iterator>(v.begin() + 3, 2ul, 2ul, 3ul, 3ul) == std::strong_ordering::less); - REQUIRE(cxl::two_dim_iterator::iterator>(v.begin()+ 6, 2ul, 2ul, 3ul, 3ul) <=> it == std::strong_ordering::greater); - } -} \ No newline at end of file diff --git a/archive/iter-tests/two_dim.create.test.cpp b/archive/iter-tests/two_dim.create.test.cpp deleted file mode 100644 index 814802b..0000000 --- a/archive/iter-tests/two_dim.create.test.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include - -TEST_CASE("Creating two_dim_iterators") -{ - SECTION("Default Constructor") - { - cxl::two_dim_iterator::iterator> it; - REQUIRE(it.base() == std::vector::iterator()); - REQUIRE(it.rows() == 0uL); - REQUIRE(it.columns() == 0uL); - REQUIRE(it.row_index() == 0uL); - REQUIRE(it.column_index() == 0uL); - } - - std::vector v = { 0, 1 - , 2, 3 - , 4, 5 - , 6, 7 - , 8, 9 }; - - auto it { cxl::two_dim_iterator::iterator>(v.begin(), 0ul, 0ul, 5ul, 2ul) }; - - - SECTION("Value Constructor") - { - REQUIRE(it.base() == v.begin()); - REQUIRE(it.rows() == 5ul); - REQUIRE(it.columns() == 2ul); - REQUIRE(it.row_index() == 0ul); - REQUIRE(it.column_index() == 0ul); - } - - SECTION("Copy Constructor") - { - auto copy { it }; - - REQUIRE(copy.base() == v.begin()); - REQUIRE(copy.rows() == 5ul); - REQUIRE(copy.columns() == 2ul); - REQUIRE(copy.row_index() == 0ul); - REQUIRE(copy.column_index() == 0ul); - } - - SECTION("Copy Assignment") - { - auto copy = it; - - REQUIRE(copy.base() == v.begin()); - REQUIRE(copy.rows() == 5ul); - REQUIRE(copy.columns() == 2ul); - REQUIRE(copy.row_index() == 0ul); - REQUIRE(copy.column_index() == 0ul); - } -} \ No newline at end of file diff --git a/archive/iter-tests/two_dim.members.test.cpp b/archive/iter-tests/two_dim.members.test.cpp deleted file mode 100644 index 18aa4f7..0000000 --- a/archive/iter-tests/two_dim.members.test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include - -TEST_CASE("column_iterator member functions") -{ - std::vector v { 0, 1, 2 - , 3, 4, 5 }; - auto it { cxl::two_dim_iterator::iterator>(v.begin(), 0ul, 0ul, 2ul, 3ul) }; - - SECTION("two_dim_iterator::base") - { REQUIRE(it.base() == v.begin()); } - - SECTION("two_dim_iterator::rows") - { REQUIRE(it.rows() == 2ul); } - - SECTION("two_dim_iterator::columns") - { REQUIRE(it.columns() == 3ul); } - - SECTION("two_dim_iterator::row_index") - { REQUIRE(it.row_index() == 0ul); } - - SECTION("two_dim_iterator::column_index") - { REQUIRE(it.column_index() == 0ul); } -} \ No newline at end of file diff --git a/archive/iterators/column.hpp b/archive/iterators/column.hpp deleted file mode 100644 index 16d3564..0000000 --- a/archive/iterators/column.hpp +++ /dev/null @@ -1,488 +0,0 @@ -/// -*- C++ -*- Header compatibility - -/// \brief Column Iterator -/// -/// Author: Tyler Swann (oraqlle@github.com) -/// -/// Header Version: v1.0.1 -/// -/// Date: 25-06-2022 -/// -/// License: MIT -/// -/// Copyright: Copyright (c) 2022 -/// \file column.hpp - - -#ifndef CORTEX_COLUMN_ITERATOR_HPP -# define CORTEX_COLUMN_ITERATOR_HPP 1 - - -#include -#include -#include - -#include "two_dim.hpp" - -#if __cpp_lib_three_way_comparison -# include -#endif // __cpp_lib_three_way_comparison - -#if __cpp_concepts >= 201907L -# include -#endif // __cpp_concepts >= 201907L - - -# if __cplusplus >= 201402L - -namespace cortex -{ - /// \brief Column Iterator - /// - /// \details A column iterator is an iterator that iterates a - /// given two dimensional space in column order. Incrementing - /// moves the iterator to the next item in that column and - /// vice versa for decrementing. Incrementing from the last item - /// in a column causes the iterator to jump to the first item in - /// the next column. Like wise, decrementing from the first item - /// in a column causes the iterator to jump to the last item in - /// the previous column. A column iterator is derived from the base - /// %cxl::two_dim_iterator. - /// - /// \tparam _Iterator - template - class column_iterator - : public two_dim_iterator<_Iterator> - { - protected: - using _Base = two_dim_iterator<_Iterator>; - - using __traits_type = typename _Base::__traits_type; - - public: - using iterator_type = typename _Base::iterator_type; - using iterator_category = typename _Base::iterator_category; - -// #if __cpp_concepts >= 201907L -// using iterator_concept = typename _Base::iterator_concept; -// #endif // __cpp_concepts >= 201907L - - using size_type = typename _Base::size_type; - using value_type = typename __traits_type::value_type; - using difference_type = typename __traits_type::difference_type; - using pointer = typename __traits_type::pointer; - using reference = typename __traits_type::reference; - - public: - - - /// \brief Default Constructor - /// - /// \details Constructs a column iterator with - /// the two_dim_iterators default constrcutor. - constexpr column_iterator() noexcept - : _Base() - { } - - /// \brief Explicit Value Constructor - /// - /// \details Constructs a column iterator from a reference to - /// an iterator of the underlying iterator type, the dimensions - /// the column iterator can move through and the current point - /// index the iterator points to. Calls the base class constructor. - /// - /// \param ptr type: iterator_type | qualifiers: [const, ref] - /// \param ridx type: size_type - /// \param cidx type: size_type - /// \param rows type: size_type - /// \param columns type: size_type - constexpr column_iterator(const iterator_type& ptr - , size_type ridx, size_type cidx - , size_type rows, size_type columns) noexcept - : _Base(ptr, ridx, cidx, rows, columns) - { } - - - /// \brief Pre Increment Operator - /// - /// \details Increments the iterator to the next item in the - /// column. If the iterator is at the last item in the column, - /// the iterator is set to the first item in the next column. - /// - /// \returns constexpr column_iterator& - constexpr column_iterator& operator++ () noexcept - { - auto old_ridx { this->m_ridx }; - auto old_cidx { this->m_cidx }; - - if (this->m_ridx == this->m_rows - 1) - { - this->m_ridx = size_type(); - ++this->m_cidx; - } - else - ++this->m_ridx; - - this->m_current += this->_M_index((this->m_ridx - old_ridx) - , (this->m_cidx - old_cidx)); - - return *this; - } - - - /// \brief Post Increment Operator - /// - /// \details Increments the iterator to the next item in the - /// column. If the iterator is at the last item in the column, - /// the iterator is set to the first item in the next column. - /// Returns the column iterator before the increment. - /// - /// \returns constexpr column_iterator - constexpr column_iterator operator++ (int) noexcept - { - auto old { column_iterator(*this) }; - - if (this->m_ridx == this->m_rows - 1) - { - this->m_ridx = size_type(); - ++this->m_cidx; - } - else - ++this->m_ridx; - - this->m_current += this->_M_index((this->m_ridx - old.row_index()) - , (this->m_cidx - old.column_index())); - - return old; - } - - - /// \brief Pre Decrement Operator - /// - /// \details Decrements the iterator to the previous item in the - /// column. If the iterator is at the first item in the column, - /// the iterator is set to the last item in the previous column. - /// - /// \returns constexpr column_iterator& - constexpr column_iterator& operator-- () noexcept - { - auto old_ridx { this->m_ridx }; - auto old_cidx { this->m_cidx }; - - if (this->m_ridx == size_type()) - { - this->m_ridx = this->m_rows; - this->m_cidx--; - } - - this->m_ridx--; - - this->m_current += this->_M_index((this->m_ridx - old_ridx) - , (this->m_cidx - old_cidx)); - - return *this; - } - - - /// \brief Post Decrement Operator - /// - /// \details Decrements the iterator to the previous item in the - /// column. If the iterator is at the first item in the column, - /// the iterator is set to the last item in the previous column. - /// Returns the column iterator before the decrement. - /// - /// \returns constexpr column_iterator - constexpr column_iterator operator-- (int) noexcept - { - auto old { column_iterator(*this) }; - - if (this->m_ridx == size_type()) - { - this->m_ridx = this->m_rows; - this->m_cidx--; - } - - this->m_ridx--; - - this->m_current += this->_M_index((this->m_ridx - old.row_index()) - , (this->m_cidx - old.column_index())); - - return old; - } - - - // constexpr reference operator[] (difference_type __n) noexcept - // { - // auto new_ridx { this->m_ridx + __n }; - // auto new_cidx { this->m_cidx }; - - // if (new_ridx > this->m_rows - 1) - // { - // new_ridx %= this->m_rows; - // new_cidx++; - // } - - // return *(this->m_current + this->_M_index((row - this->m_ridx), (col - this->m_cidx))); - // } - - - // constexpr column_iterator& operator+= (difference_type __step) noexcept - // { - // auto [col, row] { this->_M_point(__step + m_rows, m_rows) }; - - // this->m_current += this->_M_index((row - this->m_ridx), (col - this->m_cidx)); - // return *this; - // } - - - // constexpr column_iterator& operator-= (difference_type __step) noexcept - // { - // auto [col, row] { this->_M_point((-__step) + m_rows, m_rows) }; - - // this->m_current += this->_M_index((row - this->m_ridx), (col - this->m_cidx)); - // return *this; - // } - - - // constexpr column_iterator operator+ (difference_type __step) const noexcept - // { - // auto [col, row] { this->_M_point(__step + m_rows, m_rows) }; - - // return column_iterator(this->m_current + this->_M_index((row - this->m_ridx), (col - this->m_cidx)) - // , row, col - // , this->m_rows, this->m_columns); - // } - - - // constexpr column_iterator operator- (difference_type __step) const noexcept - // { - // auto [col, row] { this->_M_point((-__step) + m_rows, m_rows) }; - - // return column_iterator(this->m_current + this->_M_index((row - this->m_ridx), (col - this->m_cidx)) - // , row, col - // , this->m_rows, this->m_columns); - // } - }; /// class column_iterator - - - - /// \brief Addition Operator Overload. - /// - /// \details Takes an offset \param __n and a %column_iterator - /// \param __i. Constructs a new %column_iterator by adding - /// \param __n to \param __i.base(). - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __n - /// \param __i - /// \returns constexpr inline column_iterator<_Iterator, _Container> - /// - /// [constexpr] - /// [noexcept] - - // template - // constexpr inline column_iterator<_Iterator> - // operator+ (typename column_iterator<_Iterator>::difference_type __n, - // const column_iterator<_Iterator>& __i) - // noexcept - // { - // std::size_t rows { __n % __i.rows() }; - // auto cols { __n / __i.rows() }; - - // auto offset { __i.columns()/// rows + cols }; - - // //! \bug _M_index is protected - // return column_iterator(__i.base() + offset - // , __i.row_index() + rows, __i.column_index() + cols - // , __i.rows(), __i.columns()); - // } - - - /// \brief Less Than Operator - /// - /// \details Performs less-than comparison of two column - /// iterators. A column iterator is considered less than - /// another firstly, if it is at a lower column index. If the - /// column indices are equal, the column iterator is considered - /// less than another if it is at a lower row index. - /// - /// \tparam _Iterator - /// \param __lhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \param __rhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \returns true - /// \returns false - template - constexpr inline bool - operator< (const column_iterator<_Iterator>& __lhs, - const column_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs.column_index() < __rhs.column_index() ? true - : (__lhs.column_index() == __rhs.column_index() and __lhs.row_index() < __rhs.row_index()) ? true - : false; - } - - - /// \brief Greater Than Operator Overload - /// - /// \details Performs greater-than comparison of two column - /// iterators. A column iterator is considered greater than - /// another firstly, if it is at a higher column index. If the - /// column indices are equal, the column iterator is considered - /// greater than another if it is at a higher row index. - /// - /// \tparam _Iterator - /// \param __lhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \param __rhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \returns true - /// \returns false - template - constexpr inline bool - operator> (const column_iterator<_Iterator>& __lhs, - const column_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs.column_index() > __rhs.column_index() ? true - : (__lhs.column_index() == __rhs.column_index() and __lhs.row_index() > __lhs.row_index()) ? true - : false; - } - - - /// \brief Less Than or Equal Operator - /// - /// \details Performs less-than-or-equal comparison of two column - /// iterators. A column iterator is considered less than or equal - /// to another firstly, if they compare equal, secondly if they - /// compare less than. - /// - /// \tparam _Iterator - /// \param __lhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \param __rhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \returns true - /// \returns false - template - constexpr inline bool - operator<= (const column_iterator<_Iterator>& __lhs, - const column_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs == __rhs ? true - : __lhs < __rhs ? true - : false; - } - - - /// \brief Greater Than or Equal Operator - /// - /// \details Performs greater-than-or-equal comparison of two column - /// iterators. A column iterator is considered greater than or equal - /// to another firstly, if they compare equal, secondly if they - /// compare greater than. - /// - /// \tparam _Iterator - /// \param __lhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \param __rhs type: column_iterator<_Iterator> | qualifiers: [const, ref] - /// \returns true - /// \returns false - template - constexpr inline bool - operator>= (const column_iterator<_Iterator>& __lhs, - const column_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs == __rhs ? true - : __lhs > __rhs ? true - : false; - } - - -// -// /// \brief Makes a new %column_iterator. -// /// -// /// \details An adaptor for turning STL container iterators -// /// into %column_iterators. -// /// -// /// \code {.cpp} -// /// auto it = make_column_iterator(c.begin()); -// /// \endcode -// /// -// /// \tparam _Container -// /// \param __i -// /// \returns constexpr auto -> column_iterator -// /// -// /// [constexpr] -// /// [noexcept] -// -// template -// constexpr auto -// make_column(typename _Container::iterator __i) -// noexcept -// -> column_iterator -// { return column_iterator(__i); } - - - -// -// /// \brief Makes a new %column_iterator. -// /// -// /// \details An adaptor for making C-style array pointers -// /// into %column_iterators. -// /// -// /// \code {.cpp} -// /// auto it = make_normal(arr); -// /// \endcode -// /// -// /// \tparam _Iterator -// /// \tparam _Container -// /// \param __i -// /// \returns constexpr auto -> column_iterator<_Iterator, _Container> -// /// -// /// [constexpr] -// /// [noexcept] -// -// template -// constexpr auto -// make_column(_Iterator __i) -// noexcept -// -> column_iterator<_Iterator, _Container> -// { return column_iterator<_Iterator, _Container>(__i); } - - -// # if __cplusplus >= 201703L // C++17 -// -// /// \brief Makes a new %column_iterator. -// /// -// /// \details An adaptor for making STL container iterators -// /// into %column_iterators using C++17 type deduction. -// /// -// /// \code {.cpp} -// /// auto it = make_normal(c, c.begin()); -// /// \endcode -// /// -// /// \notes \param __c has the attribute [[maybe_unused]] -// /// -// /// \tparam _Container -// /// \tparam _Iterator -// /// \param __c -// /// \param __i -// /// \returns constexpr auto -> column_iterator<_Iterator, _Container> -// /// -// /// [constexpr] -// /// [noexcept] -// -// template -// constexpr auto -// make_column([[maybe_unused]] const _Container& __c, _Iterator __i) -// noexcept -// -> column_iterator<_Iterator, _Container> -// { return column_iterator<_Iterator, _Container>(__i); } -// -// # endif // __cplusplus >= 201703L - -} // namespace cortex - - -# endif // __cplusplus >= 201402L - -#endif // CORTEX_COLUMN_ITERATOR_HPP \ No newline at end of file diff --git a/archive/iterators/reverse.hpp b/archive/iterators/reverse.hpp deleted file mode 100644 index b7384bc..0000000 --- a/archive/iterators/reverse.hpp +++ /dev/null @@ -1,1040 +0,0 @@ -/// -*- C++ -*- Header compatiability - -/// \brief An iterator for iterating through a container in -/// reverse order. -/// -/// Author: Tyler Swann (oraqlle@github.com) -/// -/// Header Version: v1.0.0 -/// -/// Date: 25-06-2022 -/// -/// License: MIT -/// -/// Copyright: Copyright (c) 2022 -/// \file reverse.hpp - - -#ifndef CORTEX_REVERSE_ITERATOR_HPP -# define CORTEX_REVERSE_ITERATOR_HPP - - -#include -#include -#include - -#if __cpp_lib_three_way_comparison -# include -#endif /// __cpp_lib_three_way_comparison - -#if __cpp_concepts >= 201907L -# include -#endif /// __cpp_concepts >= 201907L - - -# if __cplusplus >= 201402L - -namespace cortex -{ - - - /// \brief Reverse Iterator - /// - /// \details This iterator applies the inverse operation to - /// an underlying iterator of type _Iterator, thus allowing - /// for reversed traversel through a container. - /// - /// \tparam _Iterator - template - class reverse_iterator - { - protected: - _Iterator m_current; - - using __traits_type = typename std::iterator_traits<_Iterator>; - - public: - using iterator_type = _Iterator; - -#if __cpp_concepts >= 201907L - using iterator_concept = std::random_access_iterator_tag; -#endif /// __cpp_concepts >= 201907L - - using iterator_category = typename __traits_type::iterator_category; - using value_type = typename __traits_type::value_type; - using difference_type = typename __traits_type::difference_type; - using pointer = typename __traits_type::pointer; - using reference = typename __traits_type::reference; - - - - /// \brief Default Constructor - /// - /// \details Initialises m_current to the default value of - /// the type _Iterator. - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator() noexcept - : m_current(iterator_type()) - {} - - - - /// \brief Copy Constructor. - /// - /// \details Uses copy semantics to initialise m_current from - /// an object as the same type as iterator_type. Because the - /// the underlying types must be the same, m_current can be - /// directly initialised from __other. - /// - /// \param __other const reference to an object of type iterator_type. - /// - /// [explicit] - /// [constexpr] - /// [noexcept] - - explicit constexpr reverse_iterator(const iterator_type& __other) noexcept - : m_current(__other) { } - - - - /// \brief Copy Constructor. - /// - /// \details Uses copy semantics to initialise m_current from - /// another %reverse_iterator object. Uses the \code {.cpp} - /// %reverse_iterator::base() - /// \endcode - /// method to access __other's underlying iterator. - /// - /// \param __other const reference to a %reverse_iterator object. - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator(const reverse_iterator& __other) noexcept - : m_current(__other.base()) { } - - - - - /// \brief Copy Assignment. - /// - /// \details Uses copy semantics to assign m_current to the - /// underlying iterator of __other. Uses the \code {.cpp} - /// %reverse_iterator::base() - /// \endcode - /// method to access __other's underlying iterator. - /// Returns a reference to this. - /// - /// \param __other - /// \returns constexpr reverse_iterator& - /// - /// [constexpr] - /// [noexcept] - /// [operator.assigment] - - constexpr reverse_iterator& operator= (const reverse_iterator& __other) noexcept - { - m_current = __other.base(); - return *this; - } - - - - - /// \brief Copy Assignment. - /// - /// \details Uses copy semantics to assign m_current to - /// __other. __other must be of type terator_type. - /// Returns a reference to this. - /// - /// \param __other - /// \returns constexpr reverse_iterator& - /// - /// [constexpr] - /// [noexcept] - /// [operator.assigment] - - constexpr reverse_iterator& operator= (const iterator_type& __other) noexcept - { - m_current = __other; - return *this; - } - - - - - /// \brief Bool Operator Overload. - /// - /// \details Returns true if m_current does not point - /// to a valid address. Returns a boolean. - /// - /// \returns true - /// \returns false - /// - /// [explicit] - /// [constexpr] - /// [trailing.const] - /// [noexcept] - - explicit constexpr operator bool() const noexcept - { return (m_current.base()) ? true : false; } - - - - /// \brief Dereference Operator Overload. - /// - /// \details Creates a tempory value of type - /// iterator_type equal to m_current. Prefix - /// decrements and - /// - /// \returns constexpr reference (T&) - /// - /// [constexpr] - /// [noexcept] - /// [trailing.const] - - constexpr reference operator* () const noexcept - { - iterator_type __tmp = m_current; - return *--__tmp; - } - - - - /// \brief Arrow Deference Operator Overload. - /// - /// \details Creates a tempory value of type - /// iterator_type equal to m_current. Prefix - /// decrements is applied to the tempory variable - /// before passing it to _S_to_pointer. The - /// return value of _S_to_pointer is returned - /// to the caller. - /// - /// \requires The type _Iterator meets the conditions - /// a being a pointer or that some variable, __t - /// supports __t.operator->(). - /// - /// \returns constexpr pointer (T*) - /// - /// [constexpr] - /// [noexcept] - /// [trailing.const] - - constexpr pointer operator-> () const noexcept -# if __cplusplus > 201703L && __cpp_concepts >= 201907L - requires std::is_pointer_v<_Iterator> - || requires(const _Iterator& __t) { __t.operator->(); } -# endif /// __cplusplus > 201703L && __cpp_concepts >= 201907L - { - iterator_type __tmp = m_current; - --__tmp; - return _S_to_pointer(__tmp); - } - - - - /// \brief Prefix Increment Operator Overload. - /// - /// \details Applies the prefix decrement operator to - /// m_current and returns a reference to this. - /// - /// \returns constexpr reverse_iterator& - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator& operator++ () noexcept - { - --m_current; - return *this; - } - - - - /// \brief Postfix Increment Operator Overload. - /// - /// \details Constructs tempory variable of type - /// %reverse_iterator from *this and applies the - /// prefix decrement operator on m_current. It - /// then returns a newly constructed %reverse_iterator - /// from the tempory variable. - /// - /// \returns constexpr reverse_iterator - /// - /// [constexpr] - /// [noexcept] - - constexpr reverse_iterator operator++ (int) noexcept - { - reverse_iterator __tmp = *this; - --m_current; - return __tmp; - } - - - - /// \brief Prefix Decrement Operator Overload. - /// - /// \details Applies the prefix increment operator to - /// m_current and returns a reference to this. - /// - /// \returns constexpr reverse_iterator& - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator& operator-- () noexcept - { - ++m_current; - return *this; - } - - - - /// \brief Postfix Decrement Operator Overload. - /// - /// \details Constructs tempory variable of type - /// %reverse_iterator from *this and applies the - /// prefix decrement operator on m_current. It - /// then returns a newly constructed %reverse_iterator - /// from the tempory variable. - /// - /// \returns constexpr reverse_iterator - /// - /// [constexpr] - /// [noexcept] - - constexpr reverse_iterator operator-- (int) noexcept - { - reverse_iterator __tmp = *this; - ++m_current; - return __tmp; - } - - - - /// \brief Subscript Operator Overload. - /// - /// \details Accesses the element at an offset to m_current's - /// location in memory and returns a reference to the value - /// stored at that location. - /// - /// \param __n - /// \returns constexpr reference (T&) - /// - /// [constexpr] - /// [noexcept] - /// ![range.validation] - - constexpr reference& operator[] (difference_type __n) noexcept - { return *(*this + __n); } - - - - /// \brief Additive Assignment Operator Overload. - /// - /// \details Decreases the m_current's pointer value by - /// __step and assigns m_current the new pointer value - /// and returns a reference to this. - /// - /// \param __step - /// \returns constexpr reverse_iterator& - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator& operator+= (difference_type __step) noexcept - { - m_current -= __step; - return *this; - } - - - - /// \brief Subtraction Assignment Operator Overload. - /// - /// \details Increases the m_current's pointer value by - /// __step and assigns m_current the new pointer value - /// and returns a reference to this. - /// - /// \param __step - /// \returns constexpr reverse_iterator& - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator& operator-= (difference_type __step) noexcept - { - m_current += __step; - return *this; - } - - - - /// \brief Addition Operator Overload. - /// - /// \details Constructs a new iterator from the substitution - /// of m_current and __step. - /// - /// \param __step - /// \returns constexpr reverse_iterator - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator operator+ (difference_type __step) const noexcept - { return reverse_iterator(m_current - __step); } - - - - /// \brief Subtraction Operator Overload. - /// - /// \details Constructs a new iterator from the addition - /// of m_current and __step. - /// - /// \param __step - /// \returns constexpr reverse_iterator - /// - /// [constexpr] - /// [noexcept] - constexpr reverse_iterator operator- (difference_type __step) const noexcept - { return reverse_iterator(m_current + __step); } - - - - /// \brief Base Member Access. - /// - /// \details Returns a raw copy of m_current. - /// - /// \returns constexpr iterator_type (_Iterator) - /// - /// [constexpr] - /// [noexcept] - /// [trailing.const] - - constexpr iterator_type base() const noexcept - { return m_current; } - - - - private: - - /// \brief Returns a pointer. - /// - /// \tparam _Tp - /// \param __p - /// \returns static constexpr _Tp* - /// - /// \noop - /// - /// [static] - /// [constexpr] - - template - static constexpr _Tp* _S_to_pointer(_Tp* __p) - { return __p; } - - - - - /// \brief Returns a pointer. - /// - /// \details If a object is passed, the object's arrow - /// operator is called and the result is returned. - /// - /// \tparam _Tp - /// \param __t - /// \returns static constexpr _Tp* - /// - /// [static] - /// [constexpr] - - template - static constexpr pointer _S_to_pointer(_Tp __t) - { return __t.operator->(); } - - }; /// class reverse_iterator - - -#if __cpp_lib_three_way_comparison /// C++20 - - - /// \brief Equality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %reverse_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \requires \code {.cpp} - /// { __lhsI == __rhsI } -> bool - /// \endcode - /// That the underlying _Iterator types are equality comparable. - /// - /// \exception \code {.cpp} - /// code noexcept (noexcept(__lhs.base() == __rhs.base())) - /// \endcode - /// Ensures that the comparison of __lhs.base() and - /// __rhs.base() is noexcept. - /// - /// \notes _IteratorL can equal _IteratorR. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr true - /// \returns constexpr false - /// - /// [constexpr] - /// [noexcept.noexcept-clause] - - template - requires requires (_IteratorL __lhsI, _IteratorR __rhsI) - { { __lhsI == __rhsI } -> std::convertible_to; } - constexpr bool - operator== (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept (noexcept(__lhs.base() == __rhs.base())) - { return __lhs.base() == __rhs.base(); } - - - - - /// \brief Spaceship Operator Overload. - /// - /// \details Performs a 3-way comparison of two - /// %reverse_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \exception \code {.cpp} - /// code noexcept (noexcept(__lhs.base() <=> __rhs.base())) - /// \endcode - /// Ensures that the 3-way comparison of __lhs.base() and - /// __rhs.base() is noexcept. - /// - /// \notes _IteratorL can equal _IteratorR. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr auto of [std::strong_ordering] - /// : [std::weak_ordering] - /// : [std::partial_ordering] - /// - /// [constexpr] - /// [noexcept.noexcept-clause] - - template - constexpr auto - operator<=> (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept (noexcept(__lhs.base() <=> __rhs.base())) - { return __lhs.base() <=> __rhs.base(); } - - -#else /// ! C++20 - - - - /// \brief Equality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %reverse_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator== (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() == __rhs.base(); } - - - - - /// \brief Equality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %reverse_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator== (const reverse_iterator<_Iterator>& __lhs, - const reverse_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() == __rhs.base(); } - - - - - /// \brief Inequality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %reverse_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator!= (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() != __rhs.base(); } - - - - - /// \brief Inequality Operator Overload. - /// - /// \details Performs an inequality comparison of two - /// %reverse_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator!= (const reverse_iterator<_Iterator>& __lhs, - const reverse_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() != __rhs.base(); } - - - - - /// \brief Less-than Operator Overload. - /// - /// \details Performs an less-than comparison of two - /// %reverse_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator< (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() < __rhs.base(); } - - - - - /// \brief Less-than Operator Overload. - /// - /// \details Performs an less-than comparison of two - /// %reverse_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator< (const reverse_iterator<_Iterator>& __lhs, - const reverse_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() < __rhs.base(); } - - - - - /// \brief Greater-than Operator Overload. - /// - /// \details Performs an greater-than comparison of two - /// %reverse_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator> (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() > __rhs.base(); } - - - - - /// \brief Greater-than Operator Overload. - /// - /// \details Performs an greater-than comparison - /// of two %reverse_iterator's whose _Iterator types - /// and _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator> (const reverse_iterator<_Iterator>& __lhs, - const reverse_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() > __rhs.base(); } - - - - - /// \brief Less-than-or-Equal Operator Overload. - /// - /// \details Performs an less-than-or-equal comparison - /// of two %reverse_iterator's whose _Iterator types can - /// be different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator<= (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() <= __rhs.base(); } - - - - - /// \brief Less-than-or-Equal Operator Overload. - /// - /// \details Performs an less-than-or-equal comparison - /// of two %reverse_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator<= (const reverse_iterator<_Iterator>& __lhs, - const reverse_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() <= __rhs.base(); } - - - - - /// \brief Greater-than-or-Equal Operator Overload. - /// - /// \details Performs an greater-than-or-equal comparison - /// of two %reverse_iterator's whose _Iterator types can - /// be different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator>= (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() >= __rhs.base(); } - - - - - /// \brief Greater-than-or-Equal Operator Overload. - /// - /// \details Performs an greater-than-or-equal comparison - /// of two %reverse_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline bool - operator>= (const reverse_iterator<_Iterator>& __lhs, - const reverse_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() >= __rhs.base(); } - - -#endif /// __cpp_lib_three_way_comparison - - - - - /// \brief Difference Operator Overload. - /// - /// \details Performs a difference operation between - /// two %reverse_iterator's whose _Iterator types can - /// be different but share the same _Container type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \if __cplusplus >= 201103L - /// \returns constexpr inline auto -> decltype(__lhs.base() - __rhs.base()) - /// \ifnot __cplusplus >= 201103L - /// \returns inline typename reverse_iterator<_IteratorL, _Container>::difference_type - /// \endif - /// - /// [constexpr] - /// [noexcept] - - template -#if __cplusplus >= 201103L /// C++11 - constexpr inline auto - operator- (const reverse_iterator<_IteratorL>& __lhs, - const reverse_iterator<_IteratorR>& __rhs) - noexcept - -> decltype(__lhs.base() - __rhs.base()) -#else /// ! C++11 - inline typename reverse_iterator<_IteratorL, _Container>::difference_type - operator- (const reverse_iterator<_IteratorL, _Container>& __lhs, - const reverse_iterator<_IteratorR, _Container>& __rhs) -#endif /// __cplusplus >= 201103L - { return __lhs.base() - __rhs.base(); } - - - - - /// \brief Difference Operator Overload. - /// - /// \details Performs a difference operation between - /// two %reverse_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline typename reverse_iterator<_Iterator, _Container>::difference_type - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline typename reverse_iterator<_Iterator>::difference_type - operator- (const reverse_iterator<_Iterator>& __lhs, - const reverse_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() - __rhs.base(); } - - - - - /// \brief Addition Operator Overload. - /// - /// \details Takes an offset \param __n and a %reverse_iterator - /// \param __i. Constructs a new %reverse_iterator by adding - /// \param __n to \param __i.base(). - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __n - /// \param __i - /// \returns constexpr inline reverse_iterator<_Iterator, _Container> - /// - /// [constexpr] - /// [noexcept] - - template - constexpr inline reverse_iterator<_Iterator> - operator+ (typename reverse_iterator<_Iterator>::difference_type __n, - const reverse_iterator<_Iterator>& __i) - noexcept - { return reverse_iterator<_Iterator>(__i.base() - __n); } - - - - - /// \brief Makes a new %reverse_iterator. - /// - /// \details An adaptor for turning STL container iterators - /// into %reverse_iterators. - /// - /// \code {.cpp} - /// auto it = make_reverse_iterator(c.begin()); - /// \endcode - /// - /// \tparam _Container - /// \param __i - /// \returns constexpr auto -> reverse_iterator - /// - /// [constexpr] - /// [noexcept] - - template - constexpr auto - make_reverse(typename _Container::iterator __i) - noexcept - -> reverse_iterator - { return reverse_iterator(__i); } - - - - - /// \brief Makes a new %reverse_iterator. - /// - /// \details An adaptor for making C-style array pointers - /// into %reverse_iterators. - /// - /// \code {.cpp} - /// auto it = make_normal(arr); - /// \endcode - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __i - /// \returns constexpr auto -> reverse_iterator<_Iterator, _Container> - /// - /// [constexpr] - /// [noexcept] - - template - constexpr auto - make_reverse(_Iterator __i) - noexcept - -> reverse_iterator<_Iterator> - { return reverse_iterator<_Iterator>(__i); } - - - -# if __cplusplus >= 201703L /// C++17 - - /// \brief Makes a new %reverse_iterator. - /// - /// \details An adaptor for making STL container iterators - /// into %reverse_iterators using C++17 type deduction. - /// - /// \code {.cpp} - /// auto it = make_normal(c, c.begin()); - /// \endcode - /// - /// \notes \param __c has the attribute [[maybe_unused]] - /// - /// \tparam _Container - /// \tparam _Iterator - /// \param __c - /// \param __i - /// \returns constexpr auto -> reverse_iterator<_Iterator, _Container> - /// - /// [constexpr] - /// [noexcept] - - template - constexpr auto - make_reverse([[maybe_unused]] const _Container& __c, _Iterator __i) - noexcept - -> reverse_iterator<_Iterator> - { return reverse_iterator<_Iterator>(__i); } - -# endif /// __cplusplus >= 201703L -} /// namespace reverse_iterator - -# endif /// __cplusplus >= 201402L - -#endif /// CORTEX_REVERSE_ITERATOR_HPP \ No newline at end of file diff --git a/archive/iterators/row.hpp b/archive/iterators/row.hpp deleted file mode 100644 index 73ddfdc..0000000 --- a/archive/iterators/row.hpp +++ /dev/null @@ -1,479 +0,0 @@ -/// -*- C++ -*- Header compatibility - - -/// \brief Row Iterator -/// -/// Author: Tyler Swann (oraqlle@github.com) -/// -/// Header Version: v1.0.1 -/// -/// Date: 25-06-2022 -/// -/// License: MIT -/// -/// Copyright: Copyright (c) 2022 -/// \file row.hpp - - -#ifndef CORTEX_ROW_ITERATOR_HPP -# define CORTEX_ROW_ITERATOR_HPP 1 - - -#include -#include -#include - -#include "two_dim.hpp" - -#if __cpp_lib_three_way_comparison -# include -#endif /// __cpp_lib_three_way_comparison - -#if __cpp_concepts >= 201907L -# include -#endif /// __cpp_concepts >= 201907L - - -# if __cplusplus >= 201402L - -namespace cortex -{ - /// \brief Row Iterator - /// - /// \details A row iterator is a iterator that iterates a - /// given two dimensional space in row order. Incrementing - /// moves the iterator to the next item in that row and - /// vice versa for decrementing. Incrementing from the last item - /// in a row causes the iterator to jump to the first item in - /// the next row. Like wise, decrementing from the first item - /// in a row causes the iterator to jump to the last item in - /// the previous row. A column iterator is derived from the base - /// %cxl::two_dim_iterator. - /// - /// \tparam _Iterator - template - class row_iterator - : public two_dim_iterator<_Iterator> - { - protected: - using _Base = two_dim_iterator<_Iterator>; - - using __traits_type = typename _Base::__traits_type; - - public: - using iterator_type = typename _Base::iterator_type; - using iterator_category = typename _Base::iterator_category; - -// #if __cpp_concepts >= 201907L -// using iterator_concept = typename _Base::iterator_concept; -// #endif /// __cpp_concepts >= 201907L - - using size_type = typename _Base::size_type; - using value_type = typename __traits_type::value_type; - using difference_type = typename __traits_type::difference_type; - using pointer = typename __traits_type::pointer; - using reference = typename __traits_type::reference; - - public: - - /// \brief Default Constructor - /// - /// \details Constructs a row iterator with - /// the two_dim_iterators default constrcutor. - constexpr row_iterator() noexcept - : _Base() - { } - - - /// \brief Explicit Value Constrcutor - /// - /// \details Constructs a column iterator from a reference to - /// an iterator of the underlying iterator type, the dimensions - /// the column iterator can move through and the current point - /// index the iterator points to. Calls the base class constructor. - /// - /// \param ptr type: iterator_type | qualifier: [const, ref] - constexpr row_iterator(const iterator_type& ptr - , size_type ridx, size_type cidx - , size_type row, size_type col) noexcept - : _Base(ptr, ridx, cidx, row, col) - {} - - - /// \brief Pre Increment Operator - /// - /// \details Increments the iterator to the next item in the - /// row. If the iterator is at the end of the row, the iterator - /// jumps to the first item in the next row. - /// - /// \returns constexpr row_iterator& - constexpr row_iterator& operator++ () noexcept - { - auto old_ridx { this->m_ridx }; - auto old_cidx { this->m_cidx }; - - if (this->m_cidx == this->m_columns - 1) - { - this->m_cidx = size_type(); - this->m_ridx++; - } - else - this->m_cidx++; - - this->m_current += this->_M_index((this->m_ridx - old_ridx) - , (this->m_cidx - old_cidx)); - - return *this; - } - - - /// \brief Post Increment Operator - /// - /// \details Increments the iterator to the next item in the - /// row. If the iterator is at the end of the row, the iterator - /// jumps to the first item in the next row. Returns the iterator - /// before the increment. - /// - /// \returns constexpr row_iterator - constexpr row_iterator operator++ (int) noexcept - { - auto old { row_iterator(*this) }; - - if (this->m_cidx == this->m_columns - 1) - { - this->m_cidx = size_type(); - this->m_ridx++; - } - else - this->m_cidx++; - - this->m_current += this->_M_index((this->m_ridx - old.row_index()) - , (this->m_cidx - old.column_index())); - - return old; - } - - - /// \brief Pre Decrement Operator - /// - /// \details Decrements the iterator to the previous item in the - /// row. If the iterator is at the first item in the row, the - /// iterator jumps to the last item in the previous row. - /// - /// \returns constexpr row_iterator& - constexpr row_iterator& operator-- () noexcept - { - auto old_ridx { this->m_ridx }; - auto old_cidx { this->m_cidx }; - - if (this->m_cidx == size_type()) - { - this->m_cidx = this->m_columns; - this->m_ridx--; - } - - this->m_cidx--; - - this->m_current += this->_M_index((this->m_ridx - old_ridx) - , (this->m_cidx - old_cidx)); - - return *this; - } - - - /// \brief Post Decrement Operator - /// - /// \details Decrements the iterator to the previous item in the - /// row. If the iterator is at the first item in the row, the - /// iterator jumps to the last item in the previous row. Returns - /// the iterator before the decrement. - /// - /// \returns constexpr row_iterator - constexpr row_iterator operator-- (int) noexcept - { - auto old { row_iterator(*this) }; - - if (this->m_cidx == size_type()) - { - this->m_cidx = this->m_columns; - this->m_ridx--; - } - - this->m_cidx--; - - this->m_current += this->_M_index((this->m_ridx - old.row_index()) - , (this->m_cidx - old.column_index())); - - return old; - } - - - /// constexpr reference operator[] (difference_type __n) noexcept - /// { - /// size_type cols { __n / this->m_columns }; - /// auto rows { __n % this->m_columns }; - - /// return *(this->m_current + this->_M_access(rows, cols)); - /// } - - - /// constexpr row_iterator& operator+= (difference_type __step) noexcept - /// { - /// size_type cols { __step / this->m_columns }; - /// auto rows { __step % this->m_columns }; - - /// this->m_current += this->_M_access(rows, cols); - /// return *this; - /// } - - - /// constexpr row_iterator& operator-= (difference_type __step) noexcept - /// { - /// size_type cols { __step / this->m_columns }; - /// auto rows { __step % this->m_columns }; - - /// this->m_current -= this->_M_access(rows, cols); - /// return *this; - /// } - - - /// constexpr row_iterator operator+ (difference_type __step) const noexcept - /// { - /// size_type cols { __step / this->m_columns }; - /// auto rows { __step % this->m_columns }; - - /// return row_iterator(this->m_current + this->_M_access(rows, cols), this->m_ridx + rows, this->m_cidx + cols, this->m_rows, this->m_columns); - /// } - - - /// constexpr row_iterator operator- (difference_type __step) const noexcept - /// { - /// size_type cols { __step / this->m_columns }; - /// auto rows { __step % this->m_columns }; - - /// return row_iterator(this->m_current - this->_M_access(rows, cols), this->m_ridx + rows, this->m_cidx + cols, this->m_rows, this->m_columns); - /// } - - }; /// class row_iterator - - - - /// \brief Addition Operator Overload. - /// - /// \details Takes an offset \param __n and a %row_iterator - /// \param __i. Constructs a new %row_iterator by adding - /// \param __n to \param __i.base(). - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __n - /// \param __i - /// \returns constexpr inline row_iterator<_Iterator, _Container> - /// - /// [constexpr] - /// [noexcept] - - /// template - /// constexpr inline row_iterator<_Iterator> - /// operator+ (typename row_iterator<_Iterator>::difference_type __n, - /// const row_iterator<_Iterator>& __i) - /// noexcept - /// { - /// std::size_t cols { __n / __i.columns() }; - /// auto rows { __n % __i.columns() }; - - /// auto offset { __i.columns()/// rows + cols }; - - /// return row_iterator(__i.base() + offset - /// , __i.row_index() + rows, __i.column_index() + cols - /// , __i.rows(), __i.columns()); - /// } - - - /// \brief Less Than Operator - /// - /// \details Performs less-than comparison of two row - /// iterators. A row iterator is considered less than another - /// firstly, if it is at a lower row index. If the row indices - /// are equal, the row iterator is considered less than another - /// if it is at a lower column index. - /// - /// \tparam _Iterator - /// \param __lhs type: row_iterator<_Iterator> | qualifier: [const, ref] - /// \param __rhs type: row_iterator<_Iterator> | qualifier: [const, ref] - /// \returns true - /// \returns false - template - constexpr inline bool - operator< (const row_iterator<_Iterator>& __lhs, - const row_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs.row_index() < __rhs.row_index() ? true - : __lhs.row_index() == __rhs.row_index() and __lhs.column_index() < __rhs.column_index() ? true - : false; - } - - - /// \brief Greater Than Operator - /// - /// \details Performs greater-than comparison of two row - /// iterators. A row iterator is considered greater than - /// another firstly, if it is at a higher row index. If the - /// row indices are equal, the row iterator is considered - /// greater than another if it is at a higher column index. - /// - /// \tparam _Iterator - /// \param __lhs type: row_iterator<_Iterator> | qualifier: [const, ref] - /// \param __rhs type: row_iterator<_Iterator> | qualifier: [const, ref] - /// \returns true - /// \returns false - template - constexpr inline bool - operator> (const row_iterator<_Iterator>& __lhs, - const row_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs.row_index() > __rhs.row_index() ? true - : __lhs.row_index() == __rhs.row_index() and __lhs.column_index() > __rhs.column_index() ? true - : false; - } - - - /// \brief Less Than or Equal Operator - /// - /// \details Performs less-than-or-equal comparison of two row - /// iterators. A row iterator is considered less than or equal - /// to another firstly, if they compare equal, secondly if they - /// compare less than. - /// - /// \tparam _Iterator - /// \param __lhs type: row_iterator<_Iterator> | qualifier: [const, ref] - /// \param __rhs type: row_iterator<_Iterator> | qualifier: [const, ref] - /// \returns true - /// \returns false - template - constexpr inline bool - operator<= (const row_iterator<_Iterator>& __lhs, - const row_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs == __rhs ? true - : __lhs < __rhs ? true - : false; - } - - - /// \brief Greater Than or Equal Operator - /// - /// \details Performs greater-than-or-equal comparison of two row - /// iterators. A row iterator is considered greater than or equal - /// to another firstly, if they compare equal, secondly if they - /// compare greater than. - /// - /// \tparam _Iterator - /// \param __lhs - /// \param __rhs - /// \returns true - /// \returns false - template - constexpr inline bool - operator>= (const row_iterator<_Iterator>& __lhs, - const row_iterator<_Iterator>& __rhs) - noexcept - { - return __lhs == __rhs ? true - : __lhs > __rhs ? true - : false; - } - - -// -// /// \brief Makes a new %row_iterator. -// /// -// /// \details An adaptor for turning STL container iterators -// /// into %row_iterators. -// /// -// /// \code {.cpp} -// /// auto it = make_row_iterator(c.begin()); -// /// \endcode -// /// -// /// \tparam _Container -// /// \param __i -// /// \returns constexpr auto -> row_iterator -// /// -// /// [constexpr] -// /// [noexcept] -// -// template -// constexpr auto -// make_column(typename _Container::iterator __i) -// noexcept -// -> row_iterator -// { return row_iterator(__i); } - - - -// -// /// \brief Makes a new %row_iterator. -// /// -// /// \details An adaptor for making C-style array pointers -// /// into %row_iterators. -// /// -// /// \code {.cpp} -// /// auto it = make_normal(arr); -// /// \endcode -// /// -// /// \tparam _Iterator -// /// \tparam _Container -// /// \param __i -// /// \returns constexpr auto -> row_iterator<_Iterator, _Container> -// /// -// /// [constexpr] -// /// [noexcept] -// -// template -// constexpr auto -// make_column(_Iterator __i) -// noexcept -// -> row_iterator<_Iterator, _Container> -// { return row_iterator<_Iterator, _Container>(__i); } - - -// # if __cplusplus >= 201703L /// C++17 -// -// /// \brief Makes a new %row_iterator. -// /// -// /// \details An adaptor for making STL container iterators -// /// into %row_iterators using C++17 type deduction. -// /// -// /// \code {.cpp} -// /// auto it = make_normal(c, c.begin()); -// /// \endcode -// /// -// /// \notes \param __c has the attribute [[maybe_unused]] -// /// -// /// \tparam _Container -// /// \tparam _Iterator -// /// \param __c -// /// \param __i -// /// \returns constexpr auto -> row_iterator<_Iterator, _Container> -// /// -// /// [constexpr] -// /// [noexcept] -// -// template -// constexpr auto -// make_column([[maybe_unused]] const _Container& __c, _Iterator __i) -// noexcept -// -> row_iterator<_Iterator, _Container> -// { return row_iterator<_Iterator, _Container>(__i); } -// -// # endif /// __cplusplus >= 201703L - -} /// namespace cortex - - -# endif /// __cplusplus >= 201402L - -#endif /// CORTEX_ROW_ITERATOR_HPP \ No newline at end of file diff --git a/archive/iterators/two_dim.hpp b/archive/iterators/two_dim.hpp deleted file mode 100644 index 8668ea4..0000000 --- a/archive/iterators/two_dim.hpp +++ /dev/null @@ -1,705 +0,0 @@ -/// -*- C++ -*- Header compatibility - -/// \brief Two Dimensional Iterator Base Class -/// -/// Author: Tyler Swann (oraqlle@github.com) -/// -/// Header Version: v1.0.1 -/// -/// Date: 25-06-2022 -/// -/// License: MIT -/// -/// Copyright: Copyright (c) 2022 -/// \file two_dim.hpp - - -#ifndef CORTEX_TWO_DIM_ITERATOR_HPP -# define CORTEX_TWO_DIM_ITERATOR_HPP 1 - - -#include -#include -#include - -#if __cpp_lib_three_way_comparison -# include -#endif /// __cpp_lib_three_way_comparison - -#if __cpp_concepts >= 201907L -# include -#endif /// __cpp_concepts >= 201907L - - -# if __cplusplus >= 201402L - -namespace cortex -{ - /// \brief Two Dimensional Iterator - /// - /// \details The base class for a two dimensional iterator. - /// Constructs the underlying iterator and the given position - /// of the iterator and dimensions of in which it occupies. - /// - /// \notes Potential problem incrementing or decrementing the - /// default constructed object as it refers to the the default - /// constructed iterator type and causes segmentation fault on - /// dereference. - /// - /// \tparam _Iterator - template - class two_dim_iterator - { - protected: - - using __traits_type = std::iterator_traits<_Iterator>; - - public: - using iterator_type = _Iterator; - using iterator_category = std::bidirectional_iterator_tag; - -// #if __cpp_concepts >= 201907L -// using iterator_concept = std::bidirectional_iterator; -// #endif // __cpp_concepts >= 201907L - - using size_type = std::size_t; - using value_type = typename __traits_type::value_type; - using difference_type = typename __traits_type::difference_type; - using pointer = typename __traits_type::pointer; - using reference = typename __traits_type::reference; - - - protected: - iterator_type m_current; - size_type m_ridx; - size_type m_cidx; - size_type m_rows; - size_type m_columns; - - - public: - - /// \brief Deleteted Constructors - /// - /// \details The move, iterator_type copy and - /// iterator_type move constructors and assignemnts are - /// deleted as these constructors are illogical for iterator - /// types and copying just the underlying iterator does - /// not give sufficitent information to the iterator. - /// - constexpr two_dim_iterator(two_dim_iterator&&) = delete; - constexpr two_dim_iterator(const iterator_type& __other) = delete; - constexpr two_dim_iterator& operator= (two_dim_iterator&&) = delete; - constexpr two_dim_iterator& operator= (const iterator_type&) = delete; - constexpr two_dim_iterator& operator= (iterator_type&&) = delete; - - - /// \brief Default Constructor - /// - /// \details Default constructor used default definition. - constexpr two_dim_iterator() noexcept - : m_current(iterator_type()) - , m_ridx(size_type()) - , m_cidx(size_type()) - , m_rows(size_type()) - , m_columns(size_type()) - { } - - - /// \brief Copy Constructor - constexpr two_dim_iterator(const two_dim_iterator& __other) noexcept - : m_current(__other.base()) - , m_ridx(__other.m_ridx) - , m_cidx(__other.m_cidx) - , m_rows(__other.m_rows) - , m_columns(__other.m_columns) - { } - - - /// \brief Explicit Value Constructor - /// - /// \details Constructs the iterator by copying and - /// instance of the underlying iterator and the given - /// position of the iterator and dimensions in which - /// it occupies and can move. - /// - /// \param ptr type: iterator_type | qualifiers: [const, ref] - /// \param ridx type: size_type - /// \param cidx type: size_type - /// \param rows type: size_type - /// \param columns type: size_type - explicit constexpr two_dim_iterator(const iterator_type& ptr - , size_type ridx, size_type cidx - , size_type rows, size_type columns) noexcept - : m_current(ptr) - , m_ridx(ridx) - , m_cidx(cidx) - , m_rows(rows) - , m_columns(columns) - { } - - - /// \brief Copy Assignment - /// - /// \param __other type: two_dim_iterator | qualifiers: [const, ref] - /// \returns constexpr two_dim_iterator& - constexpr two_dim_iterator& operator= (const two_dim_iterator& __other) noexcept - { - m_current = __other.base(); - - m_ridx = __other.m_ridx; - m_cidx = __other.m_cidx; - - m_rows = __other.m_rows; - m_columns = __other.m_columns; - - return *this; - } - - - /// \brief Deference Operator - /// - /// \details Dereferences the underlying iterator. - /// - /// \returns reference - constexpr reference operator* () noexcept - { return *m_current; } - - - /// \brief Deference Operator - /// - /// \details Dereferences the underlying iterator - /// and returns a constant value. - /// - /// \returns constexpr reference - constexpr reference operator* () const noexcept - { return *m_current; } - - - /// \brief Indirection Operator - /// - /// \details Returns a pointer to the underlying iterator. - /// - /// \requires The underlying iterator must be a pointer type - /// or support the indirectin operator itself. - /// - /// \returns constexpr pointer - constexpr pointer operator-> () noexcept -# if __cplusplus > 201703L && __cpp_concepts >= 201907L - requires std::is_pointer_v - || requires(const iterator_type __i) { __i.operator->(); } -# endif - { return _S_to_pointer(m_current); } - - - /// \brief Indirection Operator - /// - /// \details Returns a pointer to the underlying iterator - /// and returns a constant value. - /// - /// \requires The underlying iterator must be a pointer type - /// or support the indirectin operator itself. - /// - /// \returns constexpr pointer - constexpr pointer operator-> () const noexcept -# if __cplusplus > 201703L && __cpp_concepts >= 201907L - requires std::is_pointer_v - || requires(const iterator_type __i) { __i.operator->(); } -# endif - { return _S_to_pointer(m_current); } - - - /// \brief Base Iterator - /// - /// \details Returns the underlying iterator. - /// - /// \returns constexpr const iterator_type& - constexpr const iterator_type& base() const noexcept - { return m_current; } - - - /// \brief Occupied Rows - /// - /// \details Returns the number of rows the iterator - /// moves through. - /// - /// \returns constexpr size_type - constexpr size_type rows() const noexcept - { return m_rows; } - - - /// \brief Occupied Columns - /// - /// \details Returns the number of columns the iterator - /// moves through. - /// - /// \returns constexpr size_type - constexpr size_type columns() const noexcept - { return m_columns; } - - - /// \brief Row Index - /// - /// \details Returns the current row index of the iterator. - /// - /// \returns constexpr size_type - constexpr size_type row_index() const noexcept - { return m_ridx; } - - - /// \brief Column Index - /// - /// \details Returns the current column index of the iterator. - /// - /// \returns constexpr size_type - constexpr size_type column_index() const noexcept - { return m_cidx; } - -protected: - - /// \brief Internal Index - /// - /// \details Returns the current offset of the iterator - /// from some starting posistion. - /// - /// \returns constexpr size_type - constexpr auto _M_index(auto row, auto column) const noexcept - -> decltype(m_columns * row + column) - { return m_columns * row + column;} - - private: - - /// \brief Pointer Retrieval - /// - /// \details Returns a pointer to the underlying iterator. - /// - /// \notes This function is only available if the underlying - /// iterator is a pointer type. - /// - /// \tparam _Tp - /// \returns static constexpr _Tp* - template - static constexpr _Tp* - _S_to_pointer(_Tp* __p) - { return __p; } - - - /// \brief Pointer Retrieval - /// - /// \details Returns a pointer to the underlying iterator. - /// - /// \notes This function is only available if the underlying - /// iterator is class type and thus calls the tyoes indirection - /// operator. - /// - /// \tparam _Tp - /// \returns static constexpr pointer - template - static constexpr pointer - _S_to_pointer(_Tp __t) - { return __t.operator->(); } - }; /// class two_dim_iterator - - -#if __cpp_lib_three_way_comparison /// C++20 - - /// \brief Equality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %two_dim_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \requires - /// That the underlying _Iterator types are equality comparable. - /// \code {.cpp} - /// { __lhsI == __rhsI } -> bool - /// \endcode - /// - /// \exception - /// Ensures that __lhs.base() == __rhs.base() is noexcept. - /// - /// \notes _IteratorL can equal _IteratorR. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr true - /// \returns constexpr false - /// - /// [constexpr] - /// [noexcept.noexcept-clause] - template - requires requires (_IteratorL __lhsI, _IteratorR __rhsI) - { { __lhsI == __rhsI } -> std::convertible_to; } - constexpr bool - operator== (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept (noexcept(__lhs.base() == __rhs.base())) - { return __lhs.base() == __rhs.base(); } - - - - /// \brief Spaceship Operator Overload. - /// - /// \details Performs a 3-way comparison of two - /// %two_dim_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \exception \code {.cpp} - /// code noexcept (noexcept(__lhs.base() <=> __rhs.base())) - /// \endcode - /// Ensures that the 3-way comparison of __lhs.base() and - /// __rhs.base() is noexcept. - /// - /// \notes _IteratorL can equal _IteratorR. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr auto of [std::strong_ordering] - /// : [std::weak_ordering] - /// : [std::partial_ordering] - /// - /// [constexpr] - /// [noexcept.noexcept-clause] - template - constexpr auto - operator<=> (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept (noexcept(__lhs.base() <=> __rhs.base())) - { return std::compare_three_way{}(__lhs.base(), __rhs.base()); } - - -#else // ! C++20 - - - /// \brief Equality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %two_dim_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - /// - /// [constexpr] - /// [noexcept] - template - constexpr inline bool - operator== (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() == __rhs.base(); } - - - /// \brief Equality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %two_dim_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs type: two_dim_iterator<_Iterator> | qualifier: [const, ref] - /// \param __rhs type: two_dim_iterator<_Iterator> | qualifier: [const, ref] - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator== (const two_dim_iterator<_Iterator>& __lhs, - const two_dim_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() == __rhs.base(); } - - - /// \brief Inequality Operator Overload. - /// - /// \details Performs an equality comparison of two - /// %two_dim_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator!= (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() != __rhs.base(); } - - - /// \brief Inequality Operator Overload. - /// - /// \details Performs an inequality comparison of two - /// %two_dim_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator!= (const two_dim_iterator<_Iterator>& __lhs, - const two_dim_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() != __rhs.base(); } - - - /// \brief Less-than Operator Overload. - /// - /// \details Performs an less-than comparison of two - /// %two_dim_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator< (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() < __rhs.base(); } - - - /// \brief Less-than Operator Overload. - /// - /// \details Performs an less-than comparison of two - /// %two_dim_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator< (const two_dim_iterator<_Iterator>& __lhs, - const two_dim_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() < __rhs.base(); } - - - /// \brief Greater-than Operator Overload. - /// - /// \details Performs an greater-than comparison of two - /// %two_dim_iterator's whose _Iterator types can be - /// different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator> (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() > __rhs.base(); } - - - /// \brief Greater-than Operator Overload. - /// - /// \details Performs an greater-than comparison - /// of two %two_dim_iterator's whose _Iterator types - /// and _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator> (const two_dim_iterator<_Iterator>& __lhs, - const two_dim_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() > __rhs.base(); } - - - /// \brief Less-than-or-Equal Operator Overload. - /// - /// \details Performs an less-than-or-equal comparison - /// of two %two_dim_iterator's whose _Iterator types can - /// be different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator<= (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() <= __rhs.base(); } - - - /// \brief Less-than-or-Equal Operator Overload. - /// - /// \details Performs an less-than-or-equal comparison - /// of two %two_dim_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator<= (const two_dim_iterator<_Iterator>& __lhs, - const two_dim_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() <= __rhs.base(); } - - - /// \brief Greater-than-or-Equal Operator Overload. - /// - /// \details Performs an greater-than-or-equal comparison - /// of two %two_dim_iterator's whose _Iterator types can - /// be different but of they share the same _Container - /// type. - /// - /// \tparam _IteratorL - /// \tparam _IteratorR - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator>= (const two_dim_iterator<_IteratorL>& __lhs, - const two_dim_iterator<_IteratorR>& __rhs) - noexcept - { return __lhs.base() >= __rhs.base(); } - - - /// \brief Greater-than-or-Equal Operator Overload. - /// - /// \details Performs an greater-than-or-equal comparison - /// of two %two_dim_iterator's whose _Iterator types and - /// _Container type are the same. - /// - /// \tparam _Iterator - /// \tparam _Container - /// \param __lhs - /// \param __rhs - /// \returns constexpr inline true - /// \returns constexpr inline false - template - constexpr inline bool - operator>= (const two_dim_iterator<_Iterator>& __lhs, - const two_dim_iterator<_Iterator>& __rhs) - noexcept - { return __lhs.base() >= __rhs.base(); } - - -#endif // __cpp_lib_three_way_comparison - - - - /** - * \brief Difference Operator Overload. - * - * \details Performs a difference operation between - * two %two_dim_iterator's whose _Iterator types can - * be different but share the same _Container type. - * - * \tparam _IteratorL - * \tparam _IteratorR - * \tparam _Container - * \param __lhs - * \param __rhs - * \if __cplusplus >= 201103L - * \return constexpr inline auto -> decltype(__lhs.base() - __rhs.base()) - * \ifnot __cplusplus >= 201103L - * \return inline typename two_dim_iterator<_IteratorL, _Container>::difference_type - * \endif - * - * [constexpr] - * [noexcept] - */ -// template -// #if __cplusplus >= 201103L // C++11 -// constexpr inline auto -// operator- (const two_dim_iterator<_IteratorL>& __lhs, -// const two_dim_iterator<_IteratorR>& __rhs) -// noexcept -// -> decltype(__lhs.base() - __rhs.base()) -// #else // ! C++11 -// inline typename two_dim_iterator<_IteratorL>::difference_type -// operator- (const two_dim_iterator<_IteratorL>& __lhs, -// const two_dim_iterator<_IteratorR>& __rhs) -// #endif // __cplusplus >= 201103L -// { return __lhs.base() - __rhs.base(); } - - - - /** - * \brief Difference Operator Overload. - * - * \details Performs a difference operation between - * two %two_dim_iterator's whose _Iterator types and - * _Container type are the same. - * - * \tparam _Iterator - * \tparam _Container - * \param __lhs - * \param __rhs - * \return constexpr inline typename two_dim_iterator<_Iterator, _Container>::difference_type - * - * [constexpr] - * [noexcept] - */ - // template - // constexpr inline typename two_dim_iterator<_Iterator>::difference_type - // operator- (const two_dim_iterator<_Iterator>& __lhs, - // const two_dim_iterator<_Iterator>& __rhs) - // noexcept - // { return __lhs.base() - __rhs.base(); } -} // namespace cortex - - -# endif // __cplusplus >= 201402L - -#endif // CORTEX_TWO_DIM_ITERATOR_HPP \ No newline at end of file diff --git a/bpt.yaml b/bpt.yaml index 4a77f5a..6b207ab 100644 --- a/bpt.yaml +++ b/bpt.yaml @@ -1,5 +1,5 @@ name: cortexlib -version: 0.1.2 +version: 0.2.0 test-dependencies: - catch2@2.13.9 using main diff --git a/examples/eg1.main.cpp b/examples/eg1.main.cpp index 9688dd5..1690700 100644 --- a/examples/eg1.main.cpp +++ b/examples/eg1.main.cpp @@ -1,5 +1,5 @@ #include -#include +#include template void print(const cxl::box& bx) diff --git a/include/box/box.hxx b/include/data_structures/matrix.hxx similarity index 81% rename from include/box/box.hxx rename to include/data_structures/matrix.hxx index 92a721a..c980c32 100644 --- a/include/box/box.hxx +++ b/include/data_structures/matrix.hxx @@ -1,22 +1,22 @@ -/// -*- C++ -*- Header compatibility +/// -*- C++ -*- Header compatibility -/// \brief Two dimensional data structure. +/// \brief Two dimensional array data structure. /// /// Author: Tyler Swann (tyler.swann05@gmail.com) /// -/// Header Version: v0.1.0 +/// Header Version: v0.2.0 /// -/// Date: 14-02-2023 +/// Date: 12-03-2023 /// /// License: MIT /// /// Copyright: Copyright (c) 2022-2023 -/// \file box/box.hxx +/// \file matrix.hxx #ifndef CORTEX_BOX # define CORTEX_BOX -#include +#include #include #include @@ -28,7 +28,7 @@ namespace cxl { - /// \brief Box - Two Dimensional Array + /// \brief matrix - Two Dimensional Array /// /// \details A two dimensional, owning generic /// array. Support slicing, array based operations and @@ -39,7 +39,7 @@ namespace cxl /// \tparam T /// \tparam Alloc default: std::allocator template > - class Box + class matrix { public: using value_type = T; @@ -54,8 +54,8 @@ namespace cxl using pointer = typename alloc_traits::pointer; using const_pointer = typename alloc_traits::const_pointer; - using iterator = cxl::normal_iterator; - using const_iterator = cxl::normal_iterator; + using iterator = cxl::normal_iterator; + using const_iterator = cxl::normal_iterator; using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; @@ -71,9 +71,9 @@ namespace cxl /// \brief Default Constructor /// - /// \details Default constructor for Box. + /// \details Default constructor for matrix. constexpr - Box() noexcept + matrix() noexcept : m_num_rows{ size_type{} } , m_num_columns{ size_type{} } , m_allocator{ allocator_type{} } @@ -83,12 +83,12 @@ namespace cxl /// \brief Allocator Constructor /// - /// \details Default Constructs a Box with a + /// \details Default Constructs a matrix with a /// given allocator. /// /// \param alloc type: const allocator_type& explicit constexpr - Box(const allocator_type& alloc) noexcept + matrix(const allocator_type& alloc) noexcept : m_num_rows{ size_type{} } , m_num_columns{ size_type{} } , m_allocator{ alloc } @@ -98,7 +98,7 @@ namespace cxl /// \brief Default Size Constructor /// - /// \details Constructs a Box with dimensions of + /// \details Constructs a matrix with dimensions of /// num_rows x num_columns. Values are default constructed /// or fill constructed depending on the default /// contractibility qualification. @@ -107,7 +107,7 @@ namespace cxl /// \param num_rows type: size_type /// \param alloc type: const allocator_type& explicit constexpr - Box(size_type num_rows, size_type num_columns, const allocator_type& alloc = allocator_type{}) + matrix(size_type num_rows, size_type num_columns, const allocator_type& alloc = allocator_type{}) : m_num_rows{ num_rows } , m_num_columns{ num_columns } , m_allocator{ alloc } @@ -122,7 +122,7 @@ namespace cxl /// \brief Explicit Value and Size Constructor /// - /// \details Constructs a Box with dimensions of + /// \details Constructs a matrix with dimensions of /// num_rows x num_columns. Values are constructed from /// the a constant reference to a provided fill_value. /// @@ -131,7 +131,7 @@ namespace cxl /// \param fill_value type: value_type /// \param alloc type: const allocator_type& explicit constexpr - Box(size_type num_rows, size_type num_columns, const_reference fill_value, const allocator_type& alloc = allocator_type()) + matrix(size_type num_rows, size_type num_columns, const_reference fill_value, const allocator_type& alloc = allocator_type()) : m_num_rows{ num_rows } , m_num_columns{ num_columns } , m_allocator{ alloc } @@ -141,12 +141,12 @@ namespace cxl /// \brief Copy Constructor /// - /// \details Constructs a Box that is a copy of - /// another Box of the same underlying type. + /// \details Constructs a matrix that is a copy of + /// another matrix of the same underlying type. /// - /// \param other type: const Box& + /// \param other type: const matrix& constexpr - Box(const Box& other) + matrix(const matrix& other) : m_num_rows{ other.m_num_rows } , m_num_columns{ other.m_num_columns} , m_allocator{ other.m_allocator } @@ -156,13 +156,13 @@ namespace cxl /// \brief Copy Constructor with Alternative Allocator /// - /// \details Constructs a Box that is a copy of - /// another Box of the same underlying type. + /// \details Constructs a matrix that is a copy of + /// another matrix of the same underlying type. /// - /// \param other type: const Box& + /// \param other type: const matrix& /// \param alloc type: const allocator_type& explicit constexpr - Box(const Box& other, const allocator_type& alloc) + matrix(const matrix& other, const allocator_type& alloc) : m_num_rows{ other.m_num_rows } , m_num_columns{ other.m_num_columns } , m_allocator{ alloc } @@ -173,12 +173,12 @@ namespace cxl /// \brief Move Constructor /// /// \details Moves ownership of an existing Boxes - /// resources to this Box and leaves the other Box + /// resources to this matrix and leaves the other matrix /// in a default constructed state. /// - /// \param other type: Box&& + /// \param other type: matrix&& constexpr - Box(Box&& other) noexcept + matrix(matrix&& other) noexcept : m_num_rows{ other.m_num_rows } , m_num_columns{ other.m_num_columns } , m_allocator{ std::move(other.m_allocator) } @@ -195,14 +195,14 @@ namespace cxl /// \brief Move Constructor with Alternative Allocator /// /// \details Moves ownership of an existing Boxes - /// resources to this Box and leaves the other Box + /// resources to this matrix and leaves the other matrix /// in a default constructed state. Uses an alternative - /// allocator for construction of `this` Box. + /// allocator for construction of `this` matrix. /// - /// \param other type: Box&& + /// \param other type: matrix&& /// \param alloc type: const allocator_type& explicit constexpr - Box(Box&& other, const allocator_type& alloc) noexcept + matrix(matrix&& other, const allocator_type& alloc) noexcept : m_num_rows{ other.m_num_rows } , m_num_columns{ other.m_num_columns } , m_allocator{ alloc } @@ -219,7 +219,7 @@ namespace cxl /// \brief Initialiser List Constructor /// - /// \details Uses std::initializer_list to create a Box + /// \details Uses std::initializer_list to create a matrix /// from an initializer list of initializer lists. Elements /// ownership is moved to the Boxes memory. /// @@ -228,7 +228,7 @@ namespace cxl /// \param list type: std::initializer_list> /// \param alloc type: [[maybe_unused]] const allocator_type& constexpr - Box(std::initializer_list> list, [[maybe_unused]] const allocator_type& alloc = allocator_type{}) + matrix(std::initializer_list> list, [[maybe_unused]] const allocator_type& alloc = allocator_type{}) : m_num_rows{ list.size() } , m_num_columns{ list.begin()->size() } , m_allocator{ alloc } @@ -239,7 +239,7 @@ namespace cxl for (auto row{ list.begin() }; row != list.end(); ++row) { if (row->size() != this->m_num_columns) - throw std::invalid_argument("The size of the inner std::initializer_list must be same size as the number of columns in the Box"); + throw std::invalid_argument("The size of the inner std::initializer_list must be same size as the number of columns in the matrix"); std::uninitialized_move_n(row->begin(), this->m_num_columns, m_start + offset); offset += this->m_num_columns; @@ -248,14 +248,14 @@ namespace cxl /// \brief Dimension Constructor /// - /// \details Constructs a Box from the dimensions - /// of another. The Box is default constructed. Takes - /// the result of a call to `Box::dimension()`. + /// \details Constructs a matrix from the dimensions + /// of another. The matrix is default constructed. Takes + /// the result of a call to `matrix::dimension()`. /// /// \param dimensions type: const std::tuple& /// \param alloc type: [[maybe_unused]] const allocator_type& explicit constexpr - Box(const std::tuple& dimensions, [[maybe_unused]] const allocator_type& alloc = allocator_type{}) + matrix(const std::tuple& dimensions, [[maybe_unused]] const allocator_type& alloc = allocator_type{}) : m_num_rows{ std::get<0>(dimensions) } , m_num_columns{ std::get<1>(dimensions) } , m_allocator{ alloc } @@ -270,15 +270,15 @@ namespace cxl /// \brief Copy Assignment /// - /// \details Copies the contents of another Box into - /// this Box and returns///this. If self assignment occurs + /// \details Copies the contents of another matrix into + /// this matrix and returns///this. If self assignment occurs /// then///this is returned immediately. /// - /// \param other type: const Box& - /// \returns constexpr Box& + /// \param other type: const matrix& + /// \returns constexpr matrix& constexpr auto - operator= (const Box& other) - -> Box& + operator= (const matrix& other) + -> matrix& { if (*this != other) { @@ -298,15 +298,15 @@ namespace cxl /// \brief Move Assignment /// /// \details Moves the ownership of other's resources to - /// this Box and leaves the other Box in a default + /// this matrix and leaves the other matrix in a default /// constructed state. Returns///this. If self assignment /// occurs then///this is returned immediately. /// - /// \param other type: Box&& - /// \returns constexpr Box& + /// \param other type: matrix&& + /// \returns constexpr matrix& constexpr auto - operator= (Box&& other) noexcept - -> Box& + operator= (matrix&& other) noexcept + -> matrix& { if (*this != other) { @@ -330,17 +330,17 @@ namespace cxl /// \brief Initialiser List Assignment /// - /// \details Uses std::initializer_list to create a Box + /// \details Uses std::initializer_list to create a matrix /// from an initializer list of initializer lists. Elements /// ownership is moved to the Boxes memory. /// /// \exception std::invalid_argument /// /// \param list type: [std::initializer_list>] - /// \returns constexpr Box& + /// \returns constexpr matrix& constexpr auto operator= (std::initializer_list> list) - -> Box& + -> matrix& { std::ranges::destroy(*this); _M_deallocate(m_start, size()); @@ -355,7 +355,7 @@ namespace cxl for (auto row{ list.begin() }; row != list.end(); ++row) { if (row->size() != this->m_num_columns) - throw std::invalid_argument("The size of the inner std::initializer_list must be same size as the number of columns in the Box"); + throw std::invalid_argument("The size of the inner std::initializer_list must be same size as the number of columns in the matrix"); std::uninitialized_move_n(row->begin(), this->m_num_columns, m_start + offset); offset += this->m_num_columns; @@ -366,12 +366,12 @@ namespace cxl /// \brief Destructor /// - /// \details Releases the resources of this Box - /// and leaves the Box in an uninitialized state. + /// \details Releases the resources of this matrix + /// and leaves the matrix in an uninitialized state. #if __cplusplus >= 202202L constexpr #else - ~Box() + ~matrix() #endif { if (m_start) @@ -390,8 +390,8 @@ namespace cxl /// \brief Initialiser List Assign /// /// \details Uses std::initializer_list to reassign - /// values to a Box. If the lists dimensions are not - /// the same as the Boxes dimensions, then the Box + /// values to a matrix. If the lists dimensions are not + /// the same as the Boxes dimensions, then the matrix /// is resized to match the dimensions of the list. /// /// \exception std::invalid_argument @@ -422,14 +422,14 @@ namespace cxl for (auto row{ list.begin() }; row != list.end(); ++row) { if (row->size() != this->m_num_columns) - throw std::invalid_argument("The size of the inner std::initializer_list must be same size as the number of columns in the Box"); + throw std::invalid_argument("The size of the inner std::initializer_list must be same size as the number of columns in the matrix"); std::uninitialized_move_n(row->begin(), this->m_num_columns, m_start + offset); offset += this->m_num_columns; } } - /// \brief Resizes the Box memory. + /// \brief Resizes the matrix memory. /// /// \details /// @@ -442,7 +442,7 @@ namespace cxl /// \brief Resizes Boxes memory /// - /// \details Resizes the Box to a new shape of new_rows x new_columns. + /// \details Resizes the matrix to a new shape of new_rows x new_columns. /// Resizing will cause reallocation to a new memory block if the new /// shape is larger or smaller than the current shape. For larger shape, /// previous values are copied to the new sequential memory location @@ -468,7 +468,7 @@ namespace cxl if (new_size > alloc_traits::max_size(m_allocator)) - throw std::length_error("Box resize too large"); + throw std::length_error("matrix resize too large"); else if (old_size < new_size) { @@ -500,7 +500,7 @@ namespace cxl /// \brief Erases element indicated by position /// - /// \details Erases the value of the Box at position + /// \details Erases the value of the matrix at position /// and resets it to value_type. /// /// \param position type: const_iterator @@ -538,12 +538,12 @@ namespace cxl return std::ranges::uninitialized_fill(fst, lst, value_type{}); } - /// \brief Clears the Box elements + /// \brief Clears the matrix elements /// - /// \details The elements of the Box are destroyed and - /// the memory is deallocated entirely. The Box is however, + /// \details The elements of the matrix are destroyed and + /// the memory is deallocated entirely. The matrix is however, /// left in a state where it could be re-initialised through - /// Box::resize or reassignment. + /// matrix::resize or reassignment. constexpr auto clear() -> void @@ -560,7 +560,7 @@ namespace cxl } } - /// \brief Reshape current Box elements to new dimensions + /// \brief Reshape current matrix elements to new dimensions /// /// \details Reshapes the current Boxes dimensions while /// guaranteeing that no reallocation occurs. Elements are @@ -577,7 +577,7 @@ namespace cxl auto new_size{ _M_size_check(new_rows, new_columns) }; if (new_size != size()) - throw std::length_error("Cannot reshape Box that has different total size"); + throw std::length_error("Cannot reshape matrix that has different total size"); else resize(new_rows, new_columns); } @@ -589,17 +589,17 @@ namespace cxl /// types. The swap is performed by moving ownership /// of the matrices resources. /// - /// \param other type: Box& - void swap(Box& other) noexcept + /// \param other type: matrix& + void swap(matrix& other) noexcept { - Box tmp = std::move(other); + matrix tmp = std::move(other); other = std::move(*this); *this = std::move(tmp); } /// \brief Get Allocator /// - /// \details Returns the allocator used by the Box. + /// \details Returns the allocator used by the matrix. /// /// \returns constexpr allocator_type constexpr auto @@ -607,9 +607,9 @@ namespace cxl -> allocator_type { return m_allocator; } - /// \brief Box Size + /// \brief matrix Size /// - /// \details Returns the overall size of the Box. + /// \details Returns the overall size of the matrix. /// /// \returns constexpr size_type constexpr auto @@ -624,7 +624,7 @@ namespace cxl /// \brief Number of rows /// - /// \details Returns the number of rows of the Box. + /// \details Returns the number of rows of the matrix. /// /// \returns constexpr size_type constexpr auto @@ -634,7 +634,7 @@ namespace cxl /// \brief Number of Columns /// - /// \details Returns the number of columns of the Box. + /// \details Returns the number of columns of the matrix. /// /// \returns constexpr size_type constexpr auto @@ -642,10 +642,10 @@ namespace cxl -> size_type { return m_num_columns; } - /// \brief Max Box Size + /// \brief Max matrix Size /// /// \details Returns the maximum number of elements that - /// can be stored in the Box per the allocator. + /// can be stored in the matrix per the allocator. /// /// \returns constexpr size_type constexpr auto @@ -666,7 +666,7 @@ namespace cxl /// \brief Is Square Predicate /// /// \details If the number of rows and columns - /// are equal, the Box is square. + /// are equal, the matrix is square. /// /// \returns constexpr bool constexpr auto @@ -676,7 +676,7 @@ namespace cxl /// \brief Empty /// - /// \details Checks whether the Box is empty. + /// \details Checks whether the matrix is empty. /// /// \returns constexpr bool constexpr auto @@ -708,7 +708,7 @@ namespace cxl /// /// \details Returns a reference to the element that /// is at the point position (column, row) of the - /// Box. + /// matrix. /// /// \param column type: size_type /// \param row type: size_type @@ -725,7 +725,7 @@ namespace cxl /// /// \details Returns a reference to the element that /// is at the point position (column, row) of the - /// Box. + /// matrix. /// /// \param column type: size_type /// \param row type: size_type @@ -767,7 +767,7 @@ namespace cxl /// \brief Front /// /// \details Returns a reference to the front element - /// of the Box. + /// of the matrix. /// /// \returns constexpr reference constexpr auto @@ -778,7 +778,7 @@ namespace cxl /// \brief Front /// /// \details Returns a reference to the front element - /// of the Box. + /// of the matrix. /// /// \returns constexpr const_reference constexpr auto @@ -789,7 +789,7 @@ namespace cxl /// \brief Back /// /// \details Returns a reference to the back element - /// of the Box. + /// of the matrix. /// /// \returns constexpr reference constexpr auto @@ -800,7 +800,7 @@ namespace cxl /// \brief Back /// /// \details Returns a reference to the back element - /// of the Box. + /// of the matrix. /// /// \returns constexpr const_reference constexpr auto @@ -833,7 +833,7 @@ namespace cxl /// \brief Constant Begin Iterator /// /// \details Constant iterator to the beginning - /// of the Box. + /// of the matrix. /// /// \returns constexpr const_iterator constexpr auto @@ -940,9 +940,9 @@ namespace cxl -> const_reverse_iterator { return const_reverse_iterator(begin()); } - /// \brief Box Transpose + /// \brief matrix Transpose /// - /// \details Performs a Box transpose. + /// \details Performs a matrix transpose. /// Uses std::copy over std::ranges::copy as the output /// iterator is required to be std::constructible_v which /// column_iterator doesn't satisfy yet. @@ -951,7 +951,7 @@ namespace cxl // constexpr auto // transpose() // { - // Box result(this->num_columns(), this->num_rows()); + // matrix result(this->num_columns(), this->num_rows()); // if (empty()) // return result; @@ -961,52 +961,52 @@ namespace cxl // return result; // } - /// \brief Box map + /// \brief matrix map /// - /// \details Maps a function over the Box, returning - /// the mapped Box. + /// \details Maps a function over the matrix, returning + /// the mapped matrix. /// /// \tparam F concept: std::copy_constructible /// \param func type: F - /// \returns constexpr Box> + /// \returns constexpr matrix> template constexpr auto map(F func) const - -> Box> + -> matrix> { if (empty()) - return Box>{}; + return matrix>{}; else { - Box> result(this->num_rows(), this->num_columns()); + matrix> result(this->num_rows(), this->num_columns()); std::ranges::transform(*this, result.begin(), func); return result; } } - /// \brief Box map with range + /// \brief matrix map with range /// - /// \details Maps a function over the Box and another - /// range object, returning the mapped Box. Returns an - /// empty Box if `this` is empty. + /// \details Maps a function over the matrix and another + /// range object, returning the mapped matrix. Returns an + /// empty matrix if `this` is empty. /// /// \tparam Rng concept: std::ranges::input_range /// \tparam F concept: std::copy_constructible /// \param rng type Rng&& /// \param func type F - /// \returns constexpr Box> + /// \returns constexpr matrix> template constexpr auto map(Rng&& rng, F func) const - -> Box>> + -> matrix>> { using range_elem_t = typename std::remove_cvref_t; if (empty()) - return Box>{}; + return matrix>{}; else { - Box> result(this->num_rows(), this->num_columns()); + matrix> result(this->num_rows(), this->num_columns()); std::ranges::transform(*this, rng, result.begin(), func); return result; } @@ -1014,9 +1014,9 @@ namespace cxl /// \brief Map - Iterator Pair /// - /// \details Maps a function over the Box and a range + /// \details Maps a function over the matrix and a range /// denoted by an iterator pair, returning the mapped - /// Box. Returns an empty Box if `this` is empty. + /// matrix. Returns an empty matrix if `this` is empty. /// /// \tparam It concept: std::input_iterator /// \tparam Sn concept: std::sentinel_for @@ -1024,19 +1024,19 @@ namespace cxl /// \param first type: It /// \param last type Sn /// \param func type: Fn - /// \returns constexpr Box::value_type>>> + /// \returns constexpr matrix::value_type>>> template Sn, std::copy_constructible Fn> constexpr auto map(It first, Sn last, Fn func) const - -> Box::value_type>>> + -> matrix::value_type>>> { using iterator_elem_t = typename std::remove_cvref_t::value_type>; if (empty()) - return Box>{}; + return matrix>{}; else { - Box> result(this->num_rows(), this->num_columns()); + matrix> result(this->num_rows(), this->num_columns()); std::ranges::transform(this->begin(), this->end(), first, last, result.begin(), func); return result; } @@ -1044,19 +1044,19 @@ namespace cxl /// \brief Vertical Flip /// - /// \details Performs a vertical flip of the Box. + /// \details Performs a vertical flip of the matrix. /// ie. The order of the num_rows is reversed. If - /// `this` Box is empty, an empty Box is returned + /// `this` matrix is empty, an empty matrix is returned /// with no memory allocated to it. /// /// \returns constexpr auto // constexpr auto vflip() const // { // if (empty()) - // return Box{}; + // return matrix{}; // else // { - // Box result(this->num_rows(), this->num_columns()); + // matrix result(this->num_rows(), this->num_columns()); // for (auto cidx { 0u }; cidx < this->num_columns(); ++cidx) // std::ranges::copy(this->column_begin(cidx), this->column_end(cidx), result.column_rbegin(cidx)); @@ -1067,19 +1067,19 @@ namespace cxl /// \brief Horizontal Flip /// - /// \details Performs a horizontal flip of the Box. + /// \details Performs a horizontal flip of the matrix. /// ie. The order of the num_columns is reversed. If - /// `this` Box is empty, an empty Box is returned + /// `this` matrix is empty, an empty matrix is returned /// with no memory allocated to it. /// /// \returns constexpr auto // constexpr auto hflip() const // { // if (empty()) - // return Box{}; + // return matrix{}; // else // { - // Box result(this->num_rows(), this->num_columns()); + // matrix result(this->num_rows(), this->num_columns()); // for (auto ridx { 0u }; ridx < this->num_rows(); ++ridx) // std::ranges::copy(this->row_begin(ridx), this->row_end(ridx), result.row_rbegin(ridx)); @@ -1089,18 +1089,18 @@ namespace cxl /// \brief Right Rotate /// - /// Rotates the Box 90 degrees clockwise. Inverts the - /// dimension sizes of the Box. If `this` Box is empty, - /// an empty Box is returned with no memory allocated to it. + /// Rotates the matrix 90 degrees clockwise. Inverts the + /// dimension sizes of the matrix. If `this` matrix is empty, + /// an empty matrix is returned with no memory allocated to it. /// /// \returns constexpr auto // constexpr auto rrotate() const // { // if (empty()) - // return Box{}; + // return matrix{}; // else // { - // Box result(this->num_columns(), this->num_rows()); + // matrix result(this->num_columns(), this->num_rows()); // for (auto cidx { 0u }; cidx < this->num_columns(); ++cidx) // std::ranges::copy(this->column_begin(cidx), this->column_end(cidx), result.row_rbegin(cidx)); @@ -1111,18 +1111,18 @@ namespace cxl /// \brief Left Rotate /// - /// Rotates the Box 90 degrees counter-clockwise. Inverts - /// the dimension sizes of the Box. If `this` Box is empty, - /// an empty Box is returned with no memory allocated to it. + /// Rotates the matrix 90 degrees counter-clockwise. Inverts + /// the dimension sizes of the matrix. If `this` matrix is empty, + /// an empty matrix is returned with no memory allocated to it. /// /// \returns constexpr auto // constexpr auto lrotate() const // { // if (empty()) - // return Box{}; + // return matrix{}; // else // { - // Box result(this->num_columns(), this->num_rows()); + // matrix result(this->num_columns(), this->num_rows()); // for (auto ridx { 0u }; ridx < this->num_rows(); ++ridx) // std::ranges::copy(this->row_begin(ridx), this->row_end(ridx), result.column_rbegin(ridx)); @@ -1132,9 +1132,9 @@ namespace cxl // } private: - /// \brief Allocates memory for Box + /// \brief Allocates memory for matrix /// - /// \details Allocates the memory for the Box + /// \details Allocates the memory for the matrix /// using the allocator of the container. Uses /// std::allocator_traits to get the allocators /// relevant methods. @@ -1146,9 +1146,9 @@ namespace cxl -> pointer { return n != 0 ? alloc_traits::allocate(m_allocator, n) : pointer{}; } - /// \brief Deallocates memory for Box + /// \brief Deallocates memory for matrix /// - /// \details Deallocates the memory for the Box + /// \details Deallocates the memory for the matrix /// using the allocator of the container. Uses /// std::allocator_traits to get the allocators /// relevant methods. @@ -1163,7 +1163,7 @@ namespace cxl alloc_traits::deallocate(m_allocator, ptr, n); } - /// \brief Checks index's are in the bounds of the Box + /// \brief Checks index's are in the bounds of the matrix /// /// \details Checks if column and row are withing /// the Boxes bounds. @@ -1177,7 +1177,7 @@ namespace cxl -> void { if (row >= m_num_rows || column >= m_num_columns) - throw std::out_of_range("Box::_M_range_check - index out of range."); + throw std::out_of_range("matrix::_M_range_check - index out of range."); } constexpr auto @@ -1240,7 +1240,7 @@ namespace cxl { return ptr; } #endif // __cplusplus >= 201103L - }; /// class Box + }; /// class matrix /// \brief Compares two Boxes for equality. /// @@ -1250,15 +1250,15 @@ namespace cxl /// \tparam ElemR /// \rparam lhsE type: ElemL /// \rparam rhsE type: ElemR - /// \param lhs type: const Box& - /// \param rhs type: const Box& + /// \param lhs type: const matrix& + /// \param rhs type: const matrix& /// \returns constexpr inline bool template requires requires(ElemL lhsE, ElemR rhsE) { { lhsE == rhsE } -> std::convertible_to; } constexpr inline auto - operator== (const Box& lhs, const Box& rhs) noexcept( + operator== (const matrix& lhs, const matrix& rhs) noexcept( noexcept(std::declval() == std::declval()) && noexcept(std::ranges::equal(lhs, rhs))) -> bool { @@ -1267,7 +1267,7 @@ namespace cxl return std::ranges::equal(lhs, rhs); } - /// \brief Spaceship Operator for Box + /// \brief Spaceship Operator for matrix /// /// \details Uses std::lexicographical_compare_three_way to /// compare the Boxes and generates the !=, <, >, <=, >= @@ -1275,28 +1275,28 @@ namespace cxl /// /// \tparam ElemL /// \tparam ElemR - /// \param lhs type: const Box& - /// \param lhs type: const Box& + /// \param lhs type: const matrix& + /// \param lhs type: const matrix& /// \returns constexpr inline auto template constexpr inline auto - operator<=> (const Box& lhs, const Box& rhs) + operator<=> (const matrix& lhs, const matrix& rhs) { return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), std::compare_three_way{}); } /// \brief Map Operator /// - /// \details Maps a function over the elements of a Box - /// and returns a new Box with the mapped values. + /// \details Maps a function over the elements of a matrix + /// and returns a new matrix with the mapped values. /// /// \tparam E /// \tparam F concept: std::copy_constructible - /// \param bx type: const Box& + /// \param bx type: const matrix& /// \param f type: F /// \return constexpr auto template constexpr auto - operator|| (const Box& bx, F f) noexcept - -> Box> + operator|| (const matrix& bx, F f) noexcept + -> matrix> { return bx.map(f); } } /// namespace cxl @@ -1313,11 +1313,11 @@ namespace std /// \exception std::swap is noexcept if x.swap(y) is noexcept. /// /// \tparam T - /// \param x type: const cxl::Box& - /// \param y type: const cxl::Box& + /// \param x type: const cxl::matrix& + /// \param y type: const cxl::matrix& template constexpr inline auto - swap(cxl::Box& x, cxl::Box& y) noexcept( noexcept(x.swap(y)) ) -> void + swap(cxl::matrix& x, cxl::matrix& y) noexcept( noexcept(x.swap(y)) ) -> void { x.swap(y); } } diff --git a/include/iterator/normal.hxx b/include/iterators/normal.hxx similarity index 99% rename from include/iterator/normal.hxx rename to include/iterators/normal.hxx index 4e28d8c..423895e 100644 --- a/include/iterator/normal.hxx +++ b/include/iterators/normal.hxx @@ -5,9 +5,9 @@ /// /// Author: Tyler Swann (tyler.swann05@gmail.com) /// -/// Header Version: v0.1.1 +/// Header Version: v0.1.2 /// -/// Date: 02-01-2023 +/// Date: 12-03-2023 /// /// License: MIT /// diff --git a/src/box/box.test.cxx b/src/data_structures/matrix.test.cxx similarity index 85% rename from src/box/box.test.cxx rename to src/data_structures/matrix.test.cxx index cc1405b..c93cbbe 100644 --- a/src/box/box.test.cxx +++ b/src/data_structures/matrix.test.cxx @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include @@ -14,7 +14,7 @@ TEST_CASE("Constructors and Assignments") { SECTION("Default constructor") { - cxl::Box bx; + cxl::matrix bx; REQUIRE(bx.size() == 0); REQUIRE(bx.num_rows() == 0); REQUIRE(bx.num_columns() == 0); @@ -22,7 +22,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Size Constructor") { - cxl::Box bx(4, 5); + cxl::matrix bx(4, 5); REQUIRE(bx.size() == 20); REQUIRE(bx.num_rows() == 4); REQUIRE(bx.num_columns() == 5); @@ -30,7 +30,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Size and Value Constructor") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx.size() == 20); REQUIRE(bx.num_rows() == 4); REQUIRE(bx.num_columns() == 5); @@ -38,8 +38,8 @@ TEST_CASE("Constructors and Assignments") SECTION("Copy constructor") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(bx); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(bx); REQUIRE(nbx.size() == 20); REQUIRE(nbx.num_rows() == 4); @@ -54,12 +54,12 @@ TEST_CASE("Constructors and Assignments") SECTION("Move constructor") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); for (auto& v : bx) REQUIRE(v == 1); - cxl::Box nbx(std::move(bx)); + cxl::matrix nbx(std::move(bx)); REQUIRE(nbx.size() == 20); REQUIRE(nbx.num_rows() == 4); @@ -71,7 +71,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Initializer List Constructor") { - cxl::Box bx { { 1, 2 } + cxl::matrix bx { { 1, 2 } , { 3, 4 } , { 5, 6 } , { 7, 8 } @@ -87,7 +87,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Dimension Constructor") { - cxl::Box bx(2, 5); + cxl::matrix bx(2, 5); bx = { { 1, 2, 3, 4, 5 } , { 6, 7, 8, 9, 10 } }; @@ -96,17 +96,17 @@ TEST_CASE("Constructors and Assignments") REQUIRE(bx.size() == 10); REQUIRE(bx.shape() == std::tuple{ 2, 5 }); - REQUIRE(bx == cxl::Box { { 1, 2, 3, 4, 5 } + REQUIRE(bx == cxl::matrix { { 1, 2, 3, 4, 5 } , { 6, 7, 8, 9, 10 } }); - cxl::Box nbx(bx.shape()); + cxl::matrix nbx(bx.shape()); REQUIRE(nbx.num_rows() == 2); REQUIRE(nbx.num_columns() == 5); REQUIRE(nbx.size() == 10); REQUIRE(nbx.shape() == std::tuple{ 2, 5 }); - REQUIRE(nbx == cxl::Box { { "", "", "", "", "" } + REQUIRE(nbx == cxl::matrix { { "", "", "", "", "" } , { "", "", "", "", "" } }); } } @@ -116,7 +116,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Allocator Constructor") { std::allocator alloc; - cxl::Box bx(alloc); + cxl::matrix bx(alloc); REQUIRE(bx.size() == 0); REQUIRE(bx.num_rows() == 0); REQUIRE(bx.num_columns() == 0); @@ -126,7 +126,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Size Constructor") { std::allocator alloc; - cxl::Box bx(4, 5, alloc); + cxl::matrix bx(4, 5, alloc); REQUIRE(bx.size() == 20); REQUIRE(bx.num_rows() == 4); REQUIRE(bx.num_columns() == 5); @@ -136,7 +136,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Size and Value Constructor") { std::allocator alloc; - cxl::Box bx(4, 5, 1, alloc); + cxl::matrix bx(4, 5, 1, alloc); REQUIRE(bx.size() == 20); REQUIRE(bx.num_rows() == 4); REQUIRE(bx.num_columns() == 5); @@ -146,8 +146,8 @@ TEST_CASE("Constructors and Assignments") SECTION("Copy constructor") { std::allocator alloc; - cxl::Box bx(4, 5, 1, alloc); - cxl::Box nbx(bx); + cxl::matrix bx(4, 5, 1, alloc); + cxl::matrix nbx(bx); REQUIRE(nbx.size() == 20); REQUIRE(nbx.num_rows() == 4); @@ -164,12 +164,12 @@ TEST_CASE("Constructors and Assignments") SECTION("Move constructor") { std::allocator alloc; - cxl::Box bx(4, 5, 1, alloc); + cxl::matrix bx(4, 5, 1, alloc); for (auto& v : bx) REQUIRE(v == 1); - cxl::Box nbx(std::move(bx)); + cxl::matrix nbx(std::move(bx)); REQUIRE(nbx.size() == 20); REQUIRE(nbx.num_rows() == 4); @@ -182,7 +182,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Dimension Constructor") { - cxl::Box bx(2, 5); + cxl::matrix bx(2, 5); bx = { { 1, 2, 3, 4, 5 } , { 6, 7, 8, 9, 10 } }; @@ -191,18 +191,18 @@ TEST_CASE("Constructors and Assignments") REQUIRE(bx.size() == 10); REQUIRE(bx.shape() == std::tuple{ 2, 5 }); - REQUIRE(bx == cxl::Box { { 1, 2, 3, 4, 5 } + REQUIRE(bx == cxl::matrix { { 1, 2, 3, 4, 5 } , { 6, 7, 8, 9, 10 } }); std::allocator alloc; - cxl::Box nbx(bx.shape(), alloc); + cxl::matrix nbx(bx.shape(), alloc); REQUIRE(nbx.num_rows() == 2); REQUIRE(nbx.num_columns() == 5); REQUIRE(nbx.size() == 10); REQUIRE(nbx.shape() == std::tuple{ 2, 5 }); - REQUIRE(nbx == cxl::Box { { "", "", "", "", "" } + REQUIRE(nbx == cxl::matrix { { "", "", "", "", "" } , { "", "", "", "", "" } }); } } @@ -211,8 +211,8 @@ TEST_CASE("Constructors and Assignments") { SECTION("Copy assignment") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx; + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx; REQUIRE(nbx.size() == 0); REQUIRE(nbx.num_rows() == 0); @@ -232,8 +232,8 @@ TEST_CASE("Constructors and Assignments") SECTION("Move assignment") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx; + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx; REQUIRE(nbx.size() == 0); REQUIRE(nbx.num_rows() == 0); @@ -250,7 +250,7 @@ TEST_CASE("Constructors and Assignments") SECTION("Initializer List Assignment") { - cxl::Box bx = { { 1, 2, 3 } + cxl::matrix bx = { { 1, 2, 3 } , { 4, 5, 6 } , { 7, 8, 9 } }; @@ -268,43 +268,43 @@ TEST_CASE("MetaData Access") { SECTION("Shape and Size") { - SECTION("Box::size") + SECTION("matrix::size") { - cxl::Box bx(4, 5); + cxl::matrix bx(4, 5); REQUIRE(bx.size() == 20); } - SECTION("Box::max_size") + SECTION("matrix::max_size") { std::allocator alloc; - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx.max_size() == std::allocator_traits::max_size(alloc)); } - SECTION("Box::num_rows") + SECTION("matrix::num_rows") { - cxl::Box bx(4, 5); + cxl::matrix bx(4, 5); REQUIRE(bx.num_rows() == 4); } - SECTION("Box::num_columns") + SECTION("matrix::num_columns") { - cxl::Box bx(4, 5); + cxl::matrix bx(4, 5); REQUIRE(bx.num_columns() == 5); } - SECTION("Box::shape - Tuple") + SECTION("matrix::shape - Tuple") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); auto dim = bx.shape(); REQUIRE(std::get<0>(dim) == 4); REQUIRE(std::get<1>(dim) == 5); } - SECTION("Box::shape - Structured Binding") + SECTION("matrix::shape - Structured Binding") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); auto [c, r] = bx.shape(); REQUIRE(c == 4); @@ -314,21 +314,21 @@ TEST_CASE("MetaData Access") SECTION("Resources") { - SECTION("Box::empty") + SECTION("matrix::empty") { - cxl::Box bx; + cxl::matrix bx; REQUIRE(bx.empty()); } - SECTION("Box::empty") + SECTION("matrix::empty") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(!bx.empty()); } - SECTION("Box::get_allocator") + SECTION("matrix::get_allocator") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx.get_allocator() == std::allocator()); } } @@ -336,18 +336,18 @@ TEST_CASE("MetaData Access") TEST_CASE("Modifiers") { - SECTION("Assignment - Box::assign") + SECTION("Assignment - matrix::assign") { SECTION("Same Size") { - cxl::Box bx(3, 3, 1); + cxl::matrix bx(3, 3, 1); auto ptr { bx.data() }; REQUIRE(bx.size() == 9); REQUIRE(bx.shape() == std::tuple{3, 3}); REQUIRE(bx.data() == ptr); - REQUIRE(bx == cxl::Box { { 1, 1, 1 } + REQUIRE(bx == cxl::matrix { { 1, 1, 1 } , { 1, 1, 1 } , { 1, 1, 1 } }); @@ -358,21 +358,21 @@ TEST_CASE("Modifiers") REQUIRE(bx.size() == 9); REQUIRE(bx.shape() == std::tuple{3, 3}); REQUIRE(bx.data() == ptr); - REQUIRE(bx == cxl::Box { { 1, 2, 3 } + REQUIRE(bx == cxl::matrix { { 1, 2, 3 } , { 4, 5, 6 } , { 7, 8, 9 } }); } SECTION("Larger Size") { - cxl::Box bx(3, 3, 1); + cxl::matrix bx(3, 3, 1); auto ptr { bx.data() }; REQUIRE(bx.size() == 9); REQUIRE(bx.shape() == std::tuple{3, 3}); REQUIRE(ptr == bx.data()); - REQUIRE(bx == cxl::Box { { 1, 1, 1 } + REQUIRE(bx == cxl::matrix { { 1, 1, 1 } , { 1, 1, 1 } , { 1, 1, 1 } }); @@ -385,22 +385,22 @@ TEST_CASE("Modifiers") REQUIRE(bx.size() == 12); REQUIRE(bx.shape() == std::tuple{4, 3}); REQUIRE(bx.data() != ptr); - REQUIRE(bx == cxl::Box { { 1, 2, 3 } + REQUIRE(bx == cxl::matrix { { 1, 2, 3 } , { 4, 5, 6 } , { 7, 8, 9 } , { 10, 11, 12 } }); } - SECTION("Smaller Box") + SECTION("Smaller matrix") { - cxl::Box bx(3, 3, 1); + cxl::matrix bx(3, 3, 1); auto ptr { bx.data() }; REQUIRE(bx.size() == 9); REQUIRE(bx.shape() == std::tuple{3, 3}); REQUIRE(bx.data() == ptr); - REQUIRE(bx == cxl::Box { { 1, 1, 1 } + REQUIRE(bx == cxl::matrix { { 1, 1, 1 } , { 1, 1, 1 } , { 1, 1, 1 } }); @@ -409,19 +409,19 @@ TEST_CASE("Modifiers") REQUIRE(bx.size() == 4); REQUIRE(bx.shape() == std::tuple{1, 4}); REQUIRE(bx.data() != ptr); - REQUIRE(bx == cxl::Box { { 1, 2, 3, 4 } }); + REQUIRE(bx == cxl::matrix { { 1, 2, 3, 4 } }); } - SECTION("Empty Box") + SECTION("Empty matrix") { - cxl::Box bx; + cxl::matrix bx; auto ptr { bx.data() }; REQUIRE(bx.size() == 0); REQUIRE(bx.shape() == std::tuple{0, 0}); REQUIRE(ptr == bx.data()); - REQUIRE(bx == cxl::Box { }); + REQUIRE(bx == cxl::matrix { }); bx.assign({ { 1, 2, 3 } , { 4, 5, 6 } @@ -430,7 +430,7 @@ TEST_CASE("Modifiers") REQUIRE(bx.size() == 9); REQUIRE(bx.shape() == std::tuple{3, 3}); REQUIRE(bx.data() != ptr); - REQUIRE(bx == cxl::Box { { 1, 2, 3 } + REQUIRE(bx == cxl::matrix { { 1, 2, 3 } , { 4, 5, 6 } , { 7, 8, 9 } }); } @@ -438,10 +438,10 @@ TEST_CASE("Modifiers") SECTION("Swap") { - SECTION("Box::swap") + SECTION("matrix::swap") { - cxl::Box bx(2, 3, 1); - cxl::Box nbx(7, 4, 2); + cxl::matrix bx(2, 3, 1); + cxl::matrix nbx(7, 4, 2); for (auto& v : bx) REQUIRE(v == 1); @@ -458,10 +458,10 @@ TEST_CASE("Modifiers") REQUIRE(v == 1); } - SECTION("Box - std::swap") + SECTION("matrix - std::swap") { - cxl::Box bx(2, 3, 1); - cxl::Box nbx(7, 4, 2); + cxl::matrix bx(2, 3, 1); + cxl::matrix nbx(7, 4, 2); for (auto& v : bx) REQUIRE(v == 1); @@ -481,9 +481,9 @@ TEST_CASE("Modifiers") SECTION("Removal") { - SECTION("Box::clear") + SECTION("matrix::clear") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); auto ptr { bx.begin().base() }; REQUIRE(bx.data() == std::to_address(ptr)); @@ -501,9 +501,9 @@ TEST_CASE("Modifiers") REQUIRE(bx.data() == decltype(bx)::pointer{}); } - SECTION("Box::clear - No allocated resources") + SECTION("matrix::clear - No allocated resources") { - cxl::Box bx; + cxl::matrix bx; REQUIRE(bx.empty()); REQUIRE(bx.size() == 0); @@ -518,9 +518,9 @@ TEST_CASE("Modifiers") REQUIRE(bx.data() == decltype(bx)::pointer{}); } - SECTION("Box::clear - Uninitialized Resources") + SECTION("matrix::clear - Uninitialized Resources") { - cxl::Box bx(4, 5); + cxl::matrix bx(4, 5); REQUIRE(!bx.empty()); REQUIRE(bx.size() == 20); @@ -542,14 +542,14 @@ TEST_CASE("Modifiers") { SECTION("Resize") { - SECTION("Box::resize - Larger Resize") + SECTION("matrix::resize - Larger Resize") { using namespace std::literals; /// std::string was used as it is not trivially constructable - /// and thus Box::resize will actually initialise + /// and thus matrix::resize will actually initialise /// the variable to an empty string (unlike ints) - cxl::Box bx(2, 5, "h"); + cxl::matrix bx(2, 5, "h"); REQUIRE(!bx.empty()); REQUIRE(bx.size() == 10); @@ -581,14 +581,14 @@ TEST_CASE("Modifiers") } } - SECTION("Box::resize - Smaller Resize") + SECTION("matrix::resize - Smaller Resize") { using namespace std::literals; /// std::string was used as it is not trivially constructable - /// and thus Box::resize will actually initialise + /// and thus matrix::resize will actually initialise /// the variable to an empty string (unlike ints) - cxl::Box bx(2, 5, "h"); + cxl::matrix bx(2, 5, "h"); REQUIRE(!bx.empty()); REQUIRE(bx.size() == 10); @@ -611,14 +611,14 @@ TEST_CASE("Modifiers") REQUIRE(elem == "h"s); } - SECTION("Box::resize - After clear") + SECTION("matrix::resize - After clear") { using namespace std::literals; /// std::string was used as it is not trivially constructable - /// and thus Box::resize will actually initialise + /// and thus matrix::resize will actually initialise /// the variable to an empty string (unlike ints) - cxl::Box bx(2, 5, "h"); + cxl::matrix bx(2, 5, "h"); REQUIRE(!bx.empty()); REQUIRE(bx.size() == 10); @@ -652,9 +652,9 @@ TEST_CASE("Modifiers") SECTION("Reshape") { - SECTION("Box::reshape - correct reshape") + SECTION("matrix::reshape - correct reshape") { - cxl::Box bx(4, 6, 1); + cxl::matrix bx(4, 6, 1); REQUIRE(bx.size() == 24); REQUIRE(bx.num_rows() == 4); @@ -667,9 +667,9 @@ TEST_CASE("Modifiers") REQUIRE(bx.num_columns() == 8); } - SECTION("Box::reshape - larger reshape") + SECTION("matrix::reshape - larger reshape") { - cxl::Box bx(4, 6, 1); + cxl::matrix bx(4, 6, 1); REQUIRE(bx.size() == 24); REQUIRE(bx.num_rows() == 4); @@ -682,9 +682,9 @@ TEST_CASE("Modifiers") REQUIRE(bx.num_columns() == 6); } - SECTION("Box::reshape - smaller reshape") + SECTION("matrix::reshape - smaller reshape") { - cxl::Box bx(4, 6, 1); + cxl::matrix bx(4, 6, 1); REQUIRE(bx.size() == 24); REQUIRE(bx.num_rows() == 4); @@ -697,9 +697,9 @@ TEST_CASE("Modifiers") REQUIRE(bx.num_columns() == 6); } - SECTION("Box::reshape - reshape column vector") + SECTION("matrix::reshape - reshape column vector") { - cxl::Box bx(4, 6, 1); + cxl::matrix bx(4, 6, 1); REQUIRE(bx.size() == 24); REQUIRE(bx.num_rows() == 4); @@ -712,9 +712,9 @@ TEST_CASE("Modifiers") REQUIRE(bx.num_columns() == 1); } - SECTION("Box::reshape - reshape column vector") + SECTION("matrix::reshape - reshape column vector") { - cxl::Box bx(4, 6, 1); + cxl::matrix bx(4, 6, 1); REQUIRE(bx.size() == 24); REQUIRE(bx.num_rows() == 4); @@ -731,17 +731,17 @@ TEST_CASE("Modifiers") SECTION("box::map") { - SECTION("Box only Mapping") + SECTION("matrix only Mapping") { SECTION("Lambda") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 7, 6 } , { 8, 9 } }; - cxl::Box bxcheck = { { 0, 2 } + cxl::matrix bxcheck = { { 0, 2 } , { 4, 6 } , { 8, 10 } , { 12, 14 } @@ -763,7 +763,7 @@ TEST_CASE("Modifiers") SECTION("Lambda - Empty") { - cxl::Box bx; + cxl::matrix bx; REQUIRE(bx.empty()); REQUIRE(bx.size() == 0); @@ -782,25 +782,25 @@ TEST_CASE("Modifiers") SECTION("Double Call - Intermidiate") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box ibxcheck = { { 0, 2 } + cxl::matrix ibxcheck = { { 0, 2 } , { 4, 6 } , { 8, 10 } , { 12, 14 } , { 16, 18 } }; - cxl::Box rbxcheck = { { -3, -1 } + cxl::matrix rbxcheck = { { -3, -1 } , { -7, -5 } , { -11, -9 } , { -15, -13 } @@ -831,19 +831,19 @@ TEST_CASE("Modifiers") SECTION("Double Call - Chained") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box rbxcheck = { { -3, -1 } + cxl::matrix rbxcheck = { { -3, -1 } , { -7, -5 } , { -11, -9 } , { -15, -13 } @@ -865,7 +865,7 @@ TEST_CASE("Modifiers") SECTION("Named Lambda") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } @@ -873,7 +873,7 @@ TEST_CASE("Modifiers") auto square = [](const auto& i) { return i * i; }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 4, 9 } , { 16, 25 } , { 36, 49 } @@ -894,23 +894,23 @@ TEST_CASE("Modifiers") } } - SECTION("Box and Range") + SECTION("matrix and Range") { - SECTION("Lambda - With Box") + SECTION("Lambda - With matrix") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box rbxcheck = { { 0, 2 } + cxl::matrix rbxcheck = { { 0, 2 } , { 48, -3 } , { -12, 280 } , { -24, 14 } @@ -920,7 +920,7 @@ TEST_CASE("Modifiers") REQUIRE(bx.shape() == std::tuple{ 5, 2 }); REQUIRE(bx == bxcheck); - cxl::Box x = { { 5, 2 } + cxl::matrix x = { { 5, 2 } , { 24, -1 } , { -3, 56 } , { -4, 2 } @@ -935,19 +935,19 @@ TEST_CASE("Modifiers") SECTION("Lambda - With Other Range") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box rbxcheck = { { 0, 2 } + cxl::matrix rbxcheck = { { 0, 2 } , { 48, -3 } , { -12, 280 } , { -24, 14 } @@ -968,7 +968,7 @@ TEST_CASE("Modifiers") SECTION("Named Lambda") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } @@ -976,13 +976,13 @@ TEST_CASE("Modifiers") auto add = [](const auto& x, const auto& y) { return x + y; }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box rbxcheck = { { 5, 3 } + cxl::matrix rbxcheck = { { 5, 3 } , { 26, 2 } , { 1, 61 } , { 2, 9 } @@ -992,7 +992,7 @@ TEST_CASE("Modifiers") REQUIRE(bx.shape() == std::tuple{ 5, 2 }); REQUIRE(bx == bxcheck); - cxl::Box x = { { 5, 2 } + cxl::matrix x = { { 5, 2 } , { 24, -1 } , { -3, 56 } , { -4, 2 } @@ -1006,23 +1006,23 @@ TEST_CASE("Modifiers") } } - SECTION("Box and Iterators") + SECTION("matrix and Iterators") { - SECTION("Lambda - With Box") + SECTION("Lambda - With matrix") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box rbxcheck = { { 0, 2 } + cxl::matrix rbxcheck = { { 0, 2 } , { 48, -3 } , { -12, 280 } , { -24, 14 } @@ -1032,7 +1032,7 @@ TEST_CASE("Modifiers") REQUIRE(bx.shape() == std::tuple{ 5, 2 }); REQUIRE(bx == bxcheck); - cxl::Box x = { { 5, 2 } + cxl::matrix x = { { 5, 2 } , { 24, -1 } , { -3, 56 } , { -4, 2 } @@ -1047,19 +1047,19 @@ TEST_CASE("Modifiers") SECTION("Lambda - With Other Container") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box rbxcheck = { { 0, 2 } + cxl::matrix rbxcheck = { { 0, 2 } , { 48, -3 } , { -12, 280 } , { -24, 14 } @@ -1080,7 +1080,7 @@ TEST_CASE("Modifiers") SECTION("Named Lambda") { - cxl::Box bx = { { 0, 1 } + cxl::matrix bx = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } @@ -1088,13 +1088,13 @@ TEST_CASE("Modifiers") auto add = [](const auto& x, const auto& y) { return x + y; }; - cxl::Box bxcheck = { { 0, 1 } + cxl::matrix bxcheck = { { 0, 1 } , { 2, 3 } , { 4, 5 } , { 6, 7 } , { 8, 9 } }; - cxl::Box rbxcheck = { { 5, 3 } + cxl::matrix rbxcheck = { { 5, 3 } , { 26, 2 } , { 1, 61 } , { 2, 9 } @@ -1104,7 +1104,7 @@ TEST_CASE("Modifiers") REQUIRE(bx.shape() == std::tuple{ 5, 2 }); REQUIRE(bx == bxcheck); - cxl::Box x = { { 5, 2 } + cxl::matrix x = { { 5, 2 } , { 24, -1 } , { -3, 56 } , { -4, 2 } @@ -1618,7 +1618,7 @@ TEST_CASE("Iterators") SECTION("Range for-loop") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); for (auto& elem : bx) { @@ -1630,9 +1630,9 @@ TEST_CASE("Iterators") REQUIRE(elem == 2); } - SECTION("Box::begin and Box::end") + SECTION("matrix::begin and matrix::end") { - cxl::Box bx(4, 5); + cxl::matrix bx(4, 5); std::iota(bx.begin(), bx.end(), 1); @@ -1656,7 +1656,7 @@ TEST_CASE("Iterators") { SECTION("range-for reversed") { - cxl::Box bx = { { 1, 2 } + cxl::matrix bx = { { 1, 2 } , { 3, 4 } }; std::reverse(bx.begin(), bx.end()); @@ -1666,9 +1666,9 @@ TEST_CASE("Iterators") REQUIRE(elem == v--); } - SECTION("Box::rbegin and Box::rend") + SECTION("matrix::rbegin and matrix::rend") { - cxl::Box bx(4, 5); + cxl::matrix bx(4, 5); std::iota(bx.begin(), bx.end(), 1); @@ -1695,24 +1695,24 @@ TEST_CASE("Element Access") { SECTION("Raw Data") { - SECTION("Box::data") + SECTION("matrix::data") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx.data() != nullptr); } - SECTION("Box::front") + SECTION("matrix::front") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx.front() == 1); bx.front() = 2; REQUIRE(bx.front() == 2); } - SECTION("Box::back") + SECTION("matrix::back") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx.back() == 1); bx.back() = 2; @@ -1722,9 +1722,9 @@ TEST_CASE("Element Access") SECTION("Accessors") { - SECTION("Box::at") + SECTION("matrix::at") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx.at(0, 1) == 1); bx.at(0, 1) = 2; @@ -1733,9 +1733,9 @@ TEST_CASE("Element Access") REQUIRE_THROWS_AS(bx.at(10, 1), std::out_of_range); } - SECTION("Box::operator()") + SECTION("matrix::operator()") { - cxl::Box bx(4, 5, 1); + cxl::matrix bx(4, 5, 1); REQUIRE(bx(0, 1) == 1); bx(1, 1) = 2; @@ -1754,8 +1754,8 @@ TEST_CASE("Operators") { SECTION("Equal") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 1); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 1); REQUIRE(bx == bx); REQUIRE(bx == nbx); @@ -1763,8 +1763,8 @@ TEST_CASE("Operators") SECTION("Different size") { - cxl::Box bx(5, 8, 1); - cxl::Box nbx(4, 13, 1); + cxl::matrix bx(5, 8, 1); + cxl::matrix nbx(4, 13, 1); REQUIRE(bx != nbx); REQUIRE(nbx != bx); @@ -1775,8 +1775,8 @@ TEST_CASE("Operators") { SECTION("Not Equal") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 2); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 2); REQUIRE(bx != nbx); REQUIRE(nbx != bx); @@ -1784,8 +1784,8 @@ TEST_CASE("Operators") SECTION("Different size") { - cxl::Box bx(13, 6, 1); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 1); + cxl::matrix nbx(17, 11, 1); REQUIRE(bx != nbx); REQUIRE(nbx != bx); @@ -1793,8 +1793,8 @@ TEST_CASE("Operators") SECTION("Different data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 2); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 2); REQUIRE(bx != nbx); REQUIRE(nbx != bx); @@ -1802,8 +1802,8 @@ TEST_CASE("Operators") SECTION("Different data and size") { - cxl::Box bx(13, 6, 1); - cxl::Box nbx(17, 11, 2); + cxl::matrix bx(13, 6, 1); + cxl::matrix nbx(17, 11, 2); REQUIRE(bx != nbx); REQUIRE(nbx != bx); @@ -1814,8 +1814,8 @@ TEST_CASE("Operators") { SECTION("Different data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 2); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 2); REQUIRE(bx < nbx); REQUIRE(!(nbx < bx)); @@ -1823,8 +1823,8 @@ TEST_CASE("Operators") SECTION("Different size") { - cxl::Box bx(13, 6, 1); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 1); + cxl::matrix nbx(17, 11, 1); REQUIRE(bx < nbx); REQUIRE(!(nbx < bx)); @@ -1832,8 +1832,8 @@ TEST_CASE("Operators") SECTION("Different data and size") { - cxl::Box bx(13, 6, 2); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 2); + cxl::matrix nbx(17, 11, 1); REQUIRE(!(bx < nbx)); REQUIRE(nbx < bx); @@ -1841,8 +1841,8 @@ TEST_CASE("Operators") SECTION("Same data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 1); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 1); REQUIRE(!(bx < nbx)); REQUIRE(!(nbx < bx)); @@ -1853,8 +1853,8 @@ TEST_CASE("Operators") { SECTION("Different data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 2); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 2); REQUIRE(nbx > bx); REQUIRE(!(bx > nbx)); @@ -1862,8 +1862,8 @@ TEST_CASE("Operators") SECTION("Different size") { - cxl::Box bx(13, 6, 1); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 1); + cxl::matrix nbx(17, 11, 1); REQUIRE(nbx > bx); REQUIRE(!(bx > nbx)); @@ -1871,8 +1871,8 @@ TEST_CASE("Operators") SECTION("Different data and size") { - cxl::Box bx(13, 6, 2); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 2); + cxl::matrix nbx(17, 11, 1); REQUIRE(bx > nbx); REQUIRE(!(nbx > bx)); @@ -1880,8 +1880,8 @@ TEST_CASE("Operators") SECTION("Same data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 1); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 1); REQUIRE(!(nbx > bx)); REQUIRE(!(bx > nbx)); @@ -1892,8 +1892,8 @@ TEST_CASE("Operators") { SECTION("Different data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 2); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 2); REQUIRE(bx <= nbx); REQUIRE(!(nbx <= bx)); @@ -1901,8 +1901,8 @@ TEST_CASE("Operators") SECTION("Different size") { - cxl::Box bx(13, 6, 1); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 1); + cxl::matrix nbx(17, 11, 1); REQUIRE(bx <= nbx); REQUIRE(!(nbx <= bx)); @@ -1910,8 +1910,8 @@ TEST_CASE("Operators") SECTION("Different data and size") { - cxl::Box bx(13, 6, 2); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 2); + cxl::matrix nbx(17, 11, 1); REQUIRE(bx > nbx); REQUIRE(nbx <= bx); @@ -1919,8 +1919,8 @@ TEST_CASE("Operators") SECTION("Same data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 1); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 1); REQUIRE(bx <= nbx); REQUIRE(nbx <= bx); @@ -1931,8 +1931,8 @@ TEST_CASE("Operators") { SECTION("Different data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 2); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 2); REQUIRE(nbx >= bx); REQUIRE(!(bx >= nbx)); @@ -1940,8 +1940,8 @@ TEST_CASE("Operators") SECTION("Different size") { - cxl::Box bx(13, 6, 1); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 1); + cxl::matrix nbx(17, 11, 1); REQUIRE(nbx >= bx); REQUIRE(!(bx >= nbx)); @@ -1949,8 +1949,8 @@ TEST_CASE("Operators") SECTION("Different data and size") { - cxl::Box bx(13, 6, 2); - cxl::Box nbx(17, 11, 1); + cxl::matrix bx(13, 6, 2); + cxl::matrix nbx(17, 11, 1); REQUIRE(bx >= nbx); REQUIRE(!(nbx >= bx)); @@ -1958,8 +1958,8 @@ TEST_CASE("Operators") SECTION("Same data") { - cxl::Box bx(4, 5, 1); - cxl::Box nbx(4, 5, 1); + cxl::matrix bx(4, 5, 1); + cxl::matrix nbx(4, 5, 1); REQUIRE(bx >= nbx); REQUIRE(nbx >= bx); @@ -1973,7 +1973,7 @@ TEST_CASE("Operators") { SECTION("Map - Lambda") { - cxl::Box a = { { 1, 2 } + cxl::matrix a = { { 1, 2 } , { 3, 4 } , { 5, 6 } , { 7, 8 } }; @@ -1985,7 +1985,7 @@ TEST_CASE("Operators") REQUIRE(b.size() == 8); REQUIRE(b.shape() == std::tuple{4, 2}); - REQUIRE(b == cxl::Box { { 2, 4 } + REQUIRE(b == cxl::matrix { { 2, 4 } , { 6, 8 } , { 10, 12 } , { 14, 16 } }); @@ -1993,7 +1993,7 @@ TEST_CASE("Operators") SECTION("Map - Named Lambda") { - cxl::Box a = { { 1, 2 } + cxl::matrix a = { { 1, 2 } , { 3, 4 } , { 5, 6 } , { 7, 8 } }; @@ -2007,7 +2007,7 @@ TEST_CASE("Operators") REQUIRE(b.size() == 8); REQUIRE(b.shape() == std::tuple{4, 2}); - REQUIRE(b == cxl::Box { { 2, 1 } + REQUIRE(b == cxl::matrix { { 2, 1 } , { 0, 7 } , { 6, 5 } , { 4, 11 } }); @@ -2015,7 +2015,7 @@ TEST_CASE("Operators") SECTION("Map - Chained Lambdas") { - cxl::Box a = { { 1, 2 } + cxl::matrix a = { { 1, 2 } , { 3, 4 } , { 5, 6 } , { 7, 8 } }; @@ -2028,7 +2028,7 @@ TEST_CASE("Operators") REQUIRE(b.size() == 8); REQUIRE(b.shape() == std::tuple{4, 2}); - REQUIRE(b == cxl::Box { { 1, 7 } + REQUIRE(b == cxl::matrix { { 1, 7 } , { 5, 11 } , { 9, 15 } , { 13, 19 } }); @@ -2036,7 +2036,7 @@ TEST_CASE("Operators") SECTION("Map - Chained Named Lambdas") { - cxl::Box a = { { 1, 2 } + cxl::matrix a = { { 1, 2 } , { 3, 4 } , { 5, 6 } , { 7, 8 } }; @@ -2052,7 +2052,7 @@ TEST_CASE("Operators") REQUIRE(b.size() == 8); REQUIRE(b.shape() == std::tuple{4, 2}); - REQUIRE(b == cxl::Box { { 1, 7 } + REQUIRE(b == cxl::matrix { { 1, 7 } , { 5, 11 } , { 9, 15 } , { 13, 19 } }); diff --git a/src/iterator/normal.test.cxx b/src/iterators/normal.test.cxx similarity index 99% rename from src/iterator/normal.test.cxx rename to src/iterators/normal.test.cxx index 470d13c..b3bee94 100644 --- a/src/iterator/normal.test.cxx +++ b/src/iterators/normal.test.cxx @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include