ORIGINAL
Loading...
Searching...
No Matches
containerAdapter.h
Go to the documentation of this file.
1#ifndef CONTAINERADAPTER_H
2#define CONTAINERADAPTER_H
3#include "baseList.h"
4#include "types.h"
5#include "printable.h"
6#include "comparable.h"
7#include "hash.h"
8
9
10namespace original {
47 template <typename TYPE,
48 template <typename, typename> typename SERIAL,
49 template <typename> typename ALLOC>
50 requires ExtendsOf<baseList<TYPE, ALLOC<TYPE>>, SERIAL<TYPE, ALLOC<TYPE>>>
52 : public printable,
53 public container<TYPE, ALLOC<TYPE>>,
54 public comparable<containerAdapter<TYPE, SERIAL, ALLOC>>,
55 public hashable<containerAdapter<TYPE, SERIAL, ALLOC>> {
56 protected:
63
74
75 public:
82 [[nodiscard]] u_integer size() const override;
83
89 void swap(containerAdapter& other) noexcept;
90
96 void clear();
97
105 bool contains(const TYPE &e) const override;
106
123 integer compareTo(const containerAdapter &other) const override;
124
131
138
146
149 };
150
157
158 template <typename TYPE,
159 template <typename, typename> typename SERIAL,
160 template <typename> typename ALLOC>
163 {
164 return serial_.size();
165 }
166
167 template <typename TYPE,
168 template <typename, typename> typename SERIAL,
169 template <typename> typename ALLOC>
172 {
173 if (this == &other)
174 return;
175 serial_.swap(other.serial_);
176 }
177
178 template <typename TYPE,
179 template <typename, typename> typename SERIAL,
180 template <typename> typename ALLOC>
183 serial_.clear();
184 }
185
186 template <typename TYPE,
187 template <typename, typename> typename SERIAL,
188 template <typename> typename ALLOC>
191 return serial_.contains(e);
192 }
193
194 template <typename TYPE,
195 template <typename, typename> typename SERIAL,
196 template <typename> typename ALLOC>
202
203 template <typename TYPE,
204 template <typename, typename> typename SERIAL,
205 template <typename> typename ALLOC>
211
212 template <typename TYPE,
213 template <typename, typename> typename SERIAL,
214 template <typename> typename ALLOC>
217 return "containerAdapter";
218 }
219
220 template <typename TYPE,
221 template <typename, typename> typename SERIAL,
222 template <typename> typename ALLOC>
224 auto containerAdapter<TYPE, SERIAL, ALLOC>::toString(const bool enter) const -> std::string {
225 std::stringstream ss;
226 ss << this->className() << "(";
227 bool first = true;
228 for (const auto e : this->serial_)
229 {
230 if (!first) ss << ", ";
232 first = false;
233 }
234 ss << ")";
235 if (enter) ss << "\n";
236 return ss.str();
237 }
238}
239
240namespace std {
249 template <typename TYPE,
250 template <typename, typename> typename SERIAL,
251 template <typename> typename ALLOC>
254 lhs.swap(rhs);
255 }
256}
257
258
259#endif //CONTAINERADAPTER_H
Provides a base class for variable-size serial containers.
integer compareTo(const autoPtr &other) const override
Compare reference counters.
Definition autoPtr.h:714
void swap(autoPtr &other) noexcept
Swaps the reference counters between two autoPtr instances.
Definition autoPtr.h:703
u_integer toHash() const noexcept override
Compute hash value for the pointer.
Definition autoPtr.h:735
Base class for variable-size serial containers.
Definition baseList.h:43
Base class for comparable objects.
Definition comparable.h:35
Adapter class that provides unified interface for various container types.
Definition containerAdapter.h:55
u_integer toHash() const noexcept override
Computes hash value for the container adapter.
Definition containerAdapter.h:207
SERIAL< TYPE, ALLOC< TYPE > > serial_
The underlying container instance.
Definition containerAdapter.h:62
u_integer size() const override
Returns the number of elements in the adapter.
Definition containerAdapter.h:162
containerAdapter(const SERIAL< TYPE, ALLOC< TYPE > > &serial)
Constructs a container adapter with specified underlying container.
Definition containerAdapter.h:155
void clear()
Removes all elements from the adapter.
Definition containerAdapter.h:182
std::string toString(bool enter) const override
Generates formatted string representation.
Definition containerAdapter.h:224
void swap(containerAdapter &other) noexcept
Swaps the contents of this container adapter with another.
Definition containerAdapter.h:171
integer compareTo(const containerAdapter &other) const override
Compares two container adapters lexicographically.
Definition containerAdapter.h:198
bool contains(const TYPE &e) const override
Checks for element existence in the adapter.
Definition containerAdapter.h:190
std::string className() const override
Gets class name identifier for type information.
Definition containerAdapter.h:216
Abstract base class for containers.
Definition container.h:26
Forward declaration of hashable interface template.
Definition hash.h:220
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Base class providing polymorphic string conversion capabilities.
Definition printable.h:39
static std::string formatString(const TYPE &t)
Universal value-to-string conversion with type-specific formatting.
Definition printable.h:339
Abstract base class for sequential containers with index-based access.
Definition serial.h:34
Interface for objects that can be compared.
Checks derivation or type identity using std::derived_from.
Definition types.h:472
Provides a generic hashing utility and interface for hashable types.
Main namespace for the project Original.
Definition algorithms.h:21
Standard namespace extensions for original::alternative.
Definition allocator.h:351
void swap(original::objPoolAllocator< TYPE > &lhs, original::objPoolAllocator< TYPE > &rhs) noexcept
Specialization of std::swap for objPoolAllocator.
Definition allocator.h:635
Interface for polymorphic string formatting and output.
Core type system foundations and concept definitions.