libart-paperback 0.1.0-a.1.20260122225059.e5fea306241a
PDF (1.4) library for C++
array.hxx
1#ifndef art__paperback__carousel__array_hxx_
2#define art__paperback__carousel__array_hxx_
3
4#include <art/paperback/types.hxx>
5#include <art/paperback/forward.hxx>
6
7#include <art/paperback/carousel/object-model.hxx>
8
10{
11
12 class Array
14 {
15 public:
16 /// Iterator type.
17 ///
18 using iterator = typename deque<Object>::iterator;
19
20 /// Immutable iterator type.
21 ///
22 using const_iterator = typename deque<Object>::const_iterator;
23
24 /// Constructor.
25 ///
26 Array();
27
28 /// Constructor.
29 ///
30 Array(vector<Object>);
31
32 /// Constructor.
33 ///
34 Array(Array const&);
35
36 /// Constructor.
37 ///
38 Array(Array&&);
39
40 /// Destructor.
41 ///
42 ~Array() noexcept;
43
44 /// Get the size of the array.
45 ///
46 size_t
47 size() const;
48
49 /// Check if the array is empty.
50 ///
51 bool
52 empty() const;
53
54 /// Get a reference to the first element.
55 ///
56 Object&
57 front();
58
59 /// Get a reference to the first element.
60 ///
61 Object const&
62 front() const;
63
64 /// Get a reference to the last element.
65 ///
66 Object&
67 back();
68
69 /// Get a reference to the last element.
70 ///
71 Object const&
72 back() const;
73
74 /// Get begin iterator.
75 ///
77 begin();
78
79 /// Get begin iterator.
80 ///
82 begin() const;
83
84 /// Get begin iterator.
85 ///
87 cbegin() const;
88
89 /// Get past-the-end iterator.
90 ///
92 end();
93
94 /// Get past-the-end iterator.
95 ///
97 end() const;
98
99 /// Get past-the-end iterator.
100 ///
102 cend() const;
103
104 /// Push element to the front of the array.
105 ///
106 Object&
107 push_front(Object const&);
108
109 /// Push element to the back of the array.
110 ///
111 Object&
112 push_back(Object const&);
113
114 void
115 pop_front();
116
117 void
118 pop_back();
119
120 /// Assignment.
121 ///
122 Array&
123 operator=(Array const&);
124
125 /// Assignment.
126 ///
127 Array&
128 operator=(Array&&);
129
130 /// Comparison.
131 ///
132 bool
133 operator==(Array const&) const;
134
135 /// Comparison.
136 ///
137 bool
138 operator!=(Array const&) const;
139
140 protected:
141 void
142 attach_children(Object_model::Owner&) override;
143
144 private:
145 deque<Object> _data;
146
147 };
148
149} // namespace Art::Paperback::Carousel
150
151#endif
size_t size() const
Get the size of the array.
Definition array.cxx:33
bool empty() const
Check if the array is empty.
Definition array.cxx:40
typename deque< Object >::iterator iterator
Iterator type.
Definition array.hxx:18
Object & back()
Get a reference to the last element.
Definition array.cxx:61
const_iterator cbegin() const
Get begin iterator.
Definition array.cxx:89
Object & push_front(Object const &)
Push element to the front of the array.
Definition array.cxx:117
const_iterator cend() const
Get past-the-end iterator.
Definition array.cxx:110
typename deque< Object >::const_iterator const_iterator
Immutable iterator type.
Definition array.hxx:22
iterator begin()
Get begin iterator.
Definition array.cxx:75
Object & front()
Get a reference to the first element.
Definition array.cxx:47
iterator end()
Get past-the-end iterator.
Definition array.cxx:96
Object & push_back(Object const &)
Push element to the back of the array.
Definition array.cxx:131
void attach_children(Object_model::Owner &) override
Attach any children.
Definition array.cxx:196
Array()
Constructor.
Definition array.cxx:9
~Array() noexcept
Destructor.
Definition array.cxx:28
Base class for value types.
Definition object-model.hxx:295
Represents a COS-file object.
Definition object.hxx:16
COS object model namespace.
Definition object-model.cxx:8
COS file format implementation namespace.
Definition array.cxx:6