Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
StdVectorSupport.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5#ifndef _Stroika_Foundation_Containers_Private_StdVectorSupport_h_
6#define _Stroika_Foundation_Containers_Private_StdVectorSupport_h_
7
8#include "Stroika/Foundation/StroikaPreComp.h"
9
10#include "Stroika/Foundation/Common/Common.h"
11
12#include "Stroika/Foundation/Containers/Common.h"
13
14/**
15 * \file
16 * support classes for Concrete classes 'extensions' of behavior specific to the std::vector data structure
17 */
18
20
21 /**
22 * \brief StdVectorBasedContainer is a Stroika implementation detail, but its public methods are fair game and fully supported (as used in subclasses)
23 *
24 * This mechanism allows all the array based concrete containers (such as Sequence_StdVector) to all
25 * share the same API and implementation of the API access functions (shrink_to_fit, reserve etc) but without
26 * any genericity implied in the API (just code sharing).
27 *
28 */
29 template <typename THIS_CONTAINER, typename BASE_CONTAINER>
30 class StdVectorBasedContainer : public BASE_CONTAINER {
31 public:
32 /**
33 */
34 using BASE_CONTAINER::BASE_CONTAINER;
35
36 public:
37 /*
38 * \brief Return the number of allocated vector/array elements.
39 *
40 * This optional API allows pre-reserving space as an optimization.
41 *
42 * @aliases GetCapacity ();
43 */
44 nonvirtual size_t capacity () const;
45
46 public:
47 /**
48 * This optional API allows pre-reserving space as an optimization.
49 *
50 * @aliases SetCapacity ();
51 *
52 * \note Note that this does not affect the semantics of the container.
53 *
54 * \pre slotsAllocated >= size ()
55 */
56 nonvirtual void reserve (size_t slotsAlloced);
57
58 public:
59 /**
60 * \brief Reduce the space used to store the container contents.
61 *
62 * This has no semantics, no observable behavior. But depending on the representation of
63 * the concrete container, calling this may save memory.
64 */
65 nonvirtual void shrink_to_fit ();
66 };
67
68}
69
70/*
71 ********************************************************************************
72 ***************************** Implementation Details ***************************
73 ********************************************************************************
74 */
75#include "StdVectorSupport.inl"
76
77#endif /*_Stroika_Foundation_Containers_Private_StdVectorSupport_h_ */
StdVectorBasedContainer is a Stroika implementation detail, but its public methods are fair game and ...
nonvirtual void shrink_to_fit()
Reduce the space used to store the container contents.