Skip to content

Commit 7a77c72

Browse files
committedMay 9, 2020
Renamed circular::array to circular_array
1 parent ad413b7 commit 7a77c72

13 files changed

+99
-108
lines changed
 

‎doc/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ vista_add_doc(vista-doc-vista vista.adoc)
2222
vista_add_doc(vista-doc-rationale rationale.adoc)
2323
vista_add_doc(vista-doc-algorithm algorithm.adoc)
2424
vista_add_doc(vista-doc-circular-view circular_view.adoc)
25-
include(circular/CMakeLists.txt)
25+
vista_add_doc(vista-doc-circular-array circular_array.adoc)
2626
include(map/CMakeLists.txt)
2727
include(priority/CMakeLists.txt)
2828

@@ -33,7 +33,7 @@ if (AsciiDoctor_FOUND)
3333
DEPENDS vista-doc-rationale
3434
DEPENDS vista-doc-algorithm
3535
DEPENDS vista-doc-circular-view
36-
DEPENDS vista-doc-circular
36+
DEPENDS vista-doc-circular-array
3737
DEPENDS vista-doc-map
3838
DEPENDS vista-doc-priority
3939
)

‎doc/circular/CMakeLists.txt

-5
This file was deleted.

‎doc/circular/array.adoc ‎doc/circular_array.adoc

+20-20
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
== Introduction
1313

14-
The `circular::array<T, N>` template class is a fixed-size double-ended circular queue.
14+
The `circular_array<T, N>` template class is a fixed-size double-ended circular queue.
1515

1616
The circular array has a _fixed size_, which means there can be at most `N` elements
1717
in the circular array, where `N` is determined at compile-time. Like `std::array<T, N>`,
@@ -25,8 +25,8 @@ elements.
2525

2626
=== Running Average
2727

28-
In the <<span.adoc#span-tutorial,circular span tutorial>> we ended up with a class
29-
definition for a running average containing both an array and a span.
28+
In the <<circular_view.adoc#tutorial,circular view tutorial>> we ended up with a class
29+
definition for a running average containing both an array and a view.
3030
[source,c++,numbered]
3131
----
3232
template <typename T, std::size_t N>
@@ -42,12 +42,12 @@ private:
4242
value_type sum = {};
4343
// Storage and window
4444
value_type storage[N];
45-
circular::span<value_type, N> window;
45+
circular_view<value_type, N> window;
4646
};
4747
----
48-
Combining a fixed-size storage with a circular span is exactly the purpose of
49-
the circular array, so we can replace the storage and span with
50-
`circular::array<T, N>`.
48+
Combining a fixed-size storage with a circular view is exactly the purpose of
49+
the circular array, so we can replace the storage and view with
50+
`circular_array<T, N>`.
5151
[source,c++,numbered]
5252
----
5353
template <typename T, std::size_t N>
@@ -62,15 +62,15 @@ private:
6262
static_assert(N > 0, "N must be greater than zero");
6363
value_type sum = {};
6464
// Window contains storage
65-
circular::array<value_type, N> window;
65+
circular_array<value_type, N> window;
6666
};
6767
----
6868

6969
== Design Rationale
7070

7171
This section describes the choices behind the design of the circular array.
7272

73-
The <<span.adoc#span-rationale,design rationale>> of `circular::span<T, N>` also applies,
73+
The <<circular_view.adoc#rationale,design rationale>> of `circular_view<T, N>` also applies,
7474
except the ability to use `dynamic_extent`.
7575

7676
=== std::array
@@ -92,15 +92,15 @@ There are some significant deviations.
9292

9393
== Reference
9494

95-
Defined in header `<vista/circular/array.hpp>`.
95+
Defined in header `<vista/circular_array.hpp>`.
9696

97-
Defined in namespace `vista::circular`.
97+
Defined in namespace `vista`.
9898
[source,c++]
9999
----
100100
template <
101101
typename T,
102102
std::size_t N
103-
> class array;
103+
> class circular_array;
104104
----
105105

106106
The circular array is a fixed-size circular queue.
@@ -131,7 +131,7 @@ are inserted or destroyed when the circular array is destroyed.
131131
_Constraint:_ `T` must be _DefaultConstructible_.
132132
+
133133
_Constraint:_ `T` must be _Erasable_.
134-
| `N` | The maximum number of elements in the span.
134+
| `N` | The maximum number of elements in the array.
135135
+
136136
+
137137
_Constraint:_ `N` cannot be `dynamic_extent`.
@@ -160,7 +160,7 @@ are inserted or destroyed when the circular array is destroyed.
160160
[%header,frame="topbot",grid="rows",stripes=none]
161161
|===
162162
| Member function | Description
163-
| `constexpr array() noexcept` | Creates an empty circular array.
163+
| `constexpr circular_array() noexcept` | Creates an empty circular array.
164164
+
165165
+
166166
The `N` elements of the underlying storage are default constructed.
@@ -169,7 +169,7 @@ are inserted or destroyed when the circular array is destroyed.
169169
_Ensures:_ `capacity() == N`
170170
+
171171
_Ensures:_ `size() == 0`
172-
| `constexpr array(const array<T, N>& other) noexcept(_see Remarks_)` | Creates a circular array by copying.
172+
| `constexpr circular_array(const circular_array<T, N>& other) noexcept(_see Remarks_)` | Creates a circular array by copying.
173173
+
174174
+
175175
_Constraint:_ `T` must be _CopyConstructible_.
@@ -181,7 +181,7 @@ are inserted or destroyed when the circular array is destroyed.
181181
+
182182
+
183183
_Remarks:_ `noexcept` if `value_type` is nothrow _CopyConstructible_.
184-
| `constexpr array(array<T, N>&& other) noexcept(_see Remarks_)` | Creates a circular array by moving.
184+
| `constexpr circular_array(circular_array<T, N>&& other) noexcept(_see Remarks_)` | Creates a circular array by moving.
185185
+
186186
+
187187
_Constraint:_ `T` must be _MoveConstructible_.
@@ -195,7 +195,7 @@ are inserted or destroyed when the circular array is destroyed.
195195
_Remarks:_ `noexcept` if `value_type` is nothrow _MoveConstructible_.
196196
| `template <typename... Args>
197197
+
198-
constexpr array(value_type, Args&&...) noexcept(_see Remarks_)` | Creates a circular array with elements from input.
198+
constexpr circular_array(value_type, Args&&...) noexcept(_see Remarks_)` | Creates a circular array with elements from input.
199199
+
200200
+
201201
This constructor emulates aggregate initialization.
@@ -207,7 +207,7 @@ are inserted or destroyed when the circular array is destroyed.
207207
+
208208
+
209209
_Remarks:_ `noexcept` if `value_type` is nothrow _MoveAssignable_.
210-
| `constexpr{wj}footnote:constexpr11[Not constexpr in pass:[C++11].] array& operator=(const array<T, N>& other) noexcept(_see Remarks_)` | Recreates circular array by copying.
210+
| `constexpr{wj}footnote:constexpr11[Not constexpr in pass:[C++11].] circular_array& operator=(const circular_array<T, N>& other) noexcept(_see Remarks_)` | Recreates circular array by copying.
211211
+
212212
+
213213
_Constraint:_ `T` must be _CopyAssignable_.
@@ -219,7 +219,7 @@ are inserted or destroyed when the circular array is destroyed.
219219
+
220220
+
221221
_Remarks:_ `noexcept` if `value_type` is nothrow _CopyAssignable_.
222-
| `constexpr{wj}footnote:constexpr11[] array& operator=(array&& other) noexcept(_see Remarks_)` | Recreates circular array by moving.
222+
| `constexpr{wj}footnote:constexpr11[] circular_array& operator=(circular_array&& other) noexcept(_see Remarks_)` | Recreates circular array by moving.
223223
+
224224
+
225225
All elements are inserted, but if `input.size() > N` then only the last `N` input
@@ -232,7 +232,7 @@ are inserted or destroyed when the circular array is destroyed.
232232
+
233233
+
234234
_Remarks:_ `noexcept` if `value_type` is nothrow _MoveAssignable_.
235-
| `constexpr{wj}footnote:constexpr11[] array& operator=(std::initializer_list<value_type> input) noexcept(_see Remarks_)` | Recreates circular array with elements from initializer list.
235+
| `constexpr{wj}footnote:constexpr11[] circular_circular_array& operator=(std::initializer_list<value_type> input) noexcept(_see Remarks_)` | Recreates circular array with elements from initializer list.
236236
+
237237
+
238238
All elements are inserted, but if `input.size() > N` then only the last `N` input

‎doc/circular_view.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ into a double-ended circular queue.
3030
the view.
3131
|===
3232

33+
[#tutorial]
3334
== Tutorial
3435

3536
=== Running Average
@@ -258,6 +259,7 @@ auto impulse::value() const -> value_type
258259
Other variations are possible. For instance, we could have pushed the input
259260
values at the end of the view, and then used reverse iterators in the algorithm.
260261

262+
[#rationale]
261263
== Design Rationale
262264

263265
This section describes the choices behind the design of the circular view.

‎doc/vista.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Views operate on borrowed continguous memory. Some <<rationale.adoc#,design deci
4444

4545
== Fixed-Capacity Container
4646

47-
- <<circular/array.adoc#,Circular array>> is a circular queue operating on a nested array.
47+
- <<circular_array.adoc#,Circular array>> is a circular queue operating on a nested array.
4848

4949
== Algorithm
5050

‎example/circular/average/average.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
///////////////////////////////////////////////////////////////////////////////
1313

1414
#include <type_traits>
15-
#include <vista/circular/array.hpp>
15+
#include <vista/circular_array.hpp>
1616

1717
namespace vista
1818
{
@@ -23,11 +23,11 @@ namespace example
2323

2424
template <typename T, std::size_t N>
2525
class average
26-
: protected circular::array<T, N>
26+
: protected circular_array<T, N>
2727
{
2828
static_assert(N > 0, "N must be greater than zero");
2929

30-
using window = circular::array<T, N>;
30+
using window = circular_array<T, N>;
3131

3232
public:
3333
using value_type = typename window::value_type;

‎example/circular/concurrent/queue.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include <mutex>
1515
#include <condition_variable>
16-
#include <vista/circular/array.hpp>
16+
#include <vista/circular_array.hpp>
1717

1818
namespace vista
1919
{
@@ -52,7 +52,7 @@ class concurrent_queue
5252
private:
5353
std::mutex mutex;
5454
std::condition_variable notifier;
55-
circular::array<T, N> data;
55+
circular_array<T, N> data;
5656
};
5757

5858
} // namespace example

‎example/circular/impulse/impulse.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <type_traits>
1515
#include <numeric>
1616
#include <array>
17-
#include <vista/circular/array.hpp>
17+
#include <vista/circular_array.hpp>
1818

1919
namespace vista
2020
{
@@ -59,7 +59,7 @@ class impulse
5959
}
6060

6161
private:
62-
circular::array<value_type, N> window;
62+
circular_array<value_type, N> window;
6363
std::array<value_type, N> coefficients;
6464
};
6565

‎include/vista/circular/array.hpp ‎include/vista/circular_array.hpp

+9-12
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
namespace vista
1818
{
19-
namespace circular
20-
{
2119

2220
//! @brief Fixed-sized circular buffer.
2321
//!
@@ -29,7 +27,7 @@ namespace circular
2927
//! Violation of any precondition results in undefined behavior.
3028

3129
template <typename T, std::size_t N>
32-
class array
30+
class circular_array
3331
: private std::array<T, N>,
3432
private circular_view<T, N>
3533
{
@@ -58,7 +56,7 @@ class array
5856
//! @post capacity() == N
5957
//! @post size() == 0
6058

61-
constexpr array() noexcept;
59+
constexpr circular_array() noexcept;
6260

6361
//! @brief Creates circular array by copying.
6462
//!
@@ -67,7 +65,7 @@ class array
6765
//! @post capacity() == N
6866
//! @post size() == other.size()
6967

70-
constexpr array(const array& other) noexcept(std::is_nothrow_copy_constructible<value_type>::value);
68+
constexpr circular_array(const circular_array& other) noexcept(std::is_nothrow_copy_constructible<value_type>::value);
7169

7270
//! @brief Recreates circular array by copying.
7371
//!
@@ -77,22 +75,22 @@ class array
7775
//! @post size() == other.size()
7876

7977
VISTA_CXX14_CONSTEXPR
80-
array& operator=(const array& other) noexcept(std::is_nothrow_copy_assignable<value_type>::value);
78+
circular_array& operator=(const circular_array& other) noexcept(std::is_nothrow_copy_assignable<value_type>::value);
8179

8280
//! @brief Creates circular array by moving.
8381
//!
8482
//! @post capacity() == N
8583
//! @post size() == other.size()
8684

87-
constexpr array(array&& other) noexcept(std::is_nothrow_move_constructible<value_type>::value) = default;
85+
constexpr circular_array(circular_array&& other) noexcept(std::is_nothrow_move_constructible<value_type>::value) = default;
8886

8987
//! @brief Recreates circular array by moving.
9088
//!
9189
//! @post capacity() == N
9290
//! @post size() == other.size()
9391

9492
VISTA_CXX14_CONSTEXPR
95-
array& operator=(array&& other) noexcept(std::is_nothrow_move_assignable<value_type>::value) = default;
93+
circular_array& operator=(circular_array&& other) noexcept(std::is_nothrow_move_assignable<value_type>::value) = default;
9694

9795
//! @brief Creates circular array with element from initializer list.
9896
//!
@@ -103,7 +101,7 @@ class array
103101
//! @post size() == input.size()
104102

105103
template <typename... Args>
106-
constexpr array(value_type, Args&&...) noexcept(std::is_nothrow_move_assignable<value_type>::value);
104+
constexpr circular_array(value_type, Args&&...) noexcept(std::is_nothrow_move_assignable<value_type>::value);
107105

108106
//! @brief Recreates circular array with element from initializer list.
109107
//!
@@ -114,7 +112,7 @@ class array
114112
//! @post size() == input.size()
115113

116114
VISTA_CXX14_CONSTEXPR
117-
array& operator=(std::initializer_list<value_type> input) noexcept(std::is_nothrow_move_assignable<value_type>::value);
115+
circular_array& operator=(std::initializer_list<value_type> input) noexcept(std::is_nothrow_move_assignable<value_type>::value);
118116

119117
//! @brief Checks if circular array is empty.
120118
using view::empty;
@@ -207,9 +205,8 @@ class array
207205
using view::last_unused_segment;
208206
};
209207

210-
} // namespace circular
211208
} // namespace vista
212209

213-
#include <vista/circular/detail/array.ipp>
210+
#include <vista/detail/circular_array.ipp>
214211

215212
#endif // VISTA_CIRCULAR_ARRAY_HPP

0 commit comments

Comments
 (0)
Please sign in to comment.