Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
ArraySupport.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
6
8
9 /*
10 ********************************************************************************
11 ************* ArrayBasedContainer<THIS_CONTAINER,BASE_CONTAINER> ***************
12 ********************************************************************************
13 */
14 template <typename THIS_CONTAINER, typename BASE_CONTAINER, bool USING_IREP>
15 inline size_t ArrayBasedContainer<THIS_CONTAINER, BASE_CONTAINER, USING_IREP>::capacity () const
16 {
17 if constexpr (USING_IREP) {
18 using _SafeReadRepAccessor = typename THIS_CONTAINER ::template _SafeReadRepAccessor<typename THIS_CONTAINER::IImplRepBase_>;
19 return _SafeReadRepAccessor{this}._ConstGetRep ().capacity ();
20 }
21 else {
22 using _SafeReadRepAccessor = typename THIS_CONTAINER ::template _SafeReadRepAccessor<typename THIS_CONTAINER::Rep_>;
23 return _SafeReadRepAccessor{this}._ConstGetRep ().fData_.capacity ();
24 }
25 }
26 template <typename THIS_CONTAINER, typename BASE_CONTAINER, bool USING_IREP>
28 {
29 if constexpr (USING_IREP) {
30 using _SafeReadWriteRepAccessor = typename THIS_CONTAINER ::template _SafeReadWriteRepAccessor<typename THIS_CONTAINER::IImplRepBase_>;
31 _SafeReadWriteRepAccessor{this}._GetWriteableRep ().reserve (slotsAlloced);
32 }
33 else {
34 using _SafeReadWriteRepAccessor = typename THIS_CONTAINER ::template _SafeReadWriteRepAccessor<typename THIS_CONTAINER::Rep_>;
35 return _SafeReadWriteRepAccessor{this}._GetWriteableRep ().fData_.reserve (slotsAlloced);
36 }
37 }
38 template <typename THIS_CONTAINER, typename BASE_CONTAINER, bool USING_IREP>
40 {
41 if constexpr (USING_IREP) {
42 using _SafeReadWriteRepAccessor = typename THIS_CONTAINER ::template _SafeReadWriteRepAccessor<typename THIS_CONTAINER::IImplRepBase_>;
43 _SafeReadWriteRepAccessor{this}._GetWriteableRep ().shrink_to_fit ();
44 }
45 else {
46 using _SafeReadWriteRepAccessor = typename THIS_CONTAINER ::template _SafeReadWriteRepAccessor<typename THIS_CONTAINER::Rep_>;
47 return _SafeReadWriteRepAccessor{this}._GetWriteableRep ().fData_.shrink_to_fit ();
48 }
49 }
50
51 /*
52 ********************************************************************************
53 ***** ArrayBasedContainerRepImpl<THIS_CONTAINER_REP, BASE_CONTAINER_REP> *******
54 ********************************************************************************
55 */
56 template <typename THIS_CONTAINER_REP, typename BASE_CONTAINER_REP>
58 {
59 Debug::AssertExternallySynchronizedMutex::WriteContext declareContext{Debug::UncheckedDynamicCast<THIS_CONTAINER_REP*> (this)->fData_};
60 Debug::UncheckedDynamicCast<THIS_CONTAINER_REP*> (this)->fData_.shrink_to_fit ();
61 Debug::UncheckedDynamicCast<THIS_CONTAINER_REP*> (this)->fChangeCounts_.PerformedChange ();
62 }
63 template <typename THIS_CONTAINER_REP, typename BASE_CONTAINER_REP>
64 size_t ArrayBasedContainerRepImpl<THIS_CONTAINER_REP, BASE_CONTAINER_REP>::capacity () const
65 {
66 Debug::AssertExternallySynchronizedMutex::ReadContext declareContext{Debug::UncheckedDynamicCast<const THIS_CONTAINER_REP*> (this)->fData_};
67 return Debug::UncheckedDynamicCast<const THIS_CONTAINER_REP*> (this)->fData_.capacity ();
68 }
69 template <typename THIS_CONTAINER_REP, typename BASE_CONTAINER_REP>
70 void ArrayBasedContainerRepImpl<THIS_CONTAINER_REP, BASE_CONTAINER_REP>::reserve (size_t slotsAlloced)
71 {
72 Debug::AssertExternallySynchronizedMutex::WriteContext declareContext{Debug::UncheckedDynamicCast<THIS_CONTAINER_REP*> (this)->fData_};
73 Debug::UncheckedDynamicCast<THIS_CONTAINER_REP*> (this)->fData_.reserve (slotsAlloced);
74 Debug::UncheckedDynamicCast<THIS_CONTAINER_REP*> (this)->fChangeCounts_.PerformedChange ();
75 }
76
77}
nonvirtual void shrink_to_fit()
Reduce the space used to store the container contents.
CRTP applied when ArrayBasedContainerIRep used.
shared_lock< const AssertExternallySynchronizedMutex > ReadContext
Instantiate AssertExternallySynchronizedMutex::ReadContext to designate an area of code where protect...
unique_lock< AssertExternallySynchronizedMutex > WriteContext
Instantiate AssertExternallySynchronizedMutex::WriteContext to designate an area of code where protec...