4#include "Stroika/Foundation/Containers/DataStructures/LinkedList.h"
5#include "Stroika/Foundation/Containers/Private/IteratorImplHelper.h"
14 class Collection_LinkedList<T>::Rep_ :
public IImplRep_,
public Memory::UseBlockAllocationIfAppropriate<Rep_> {
16 using inherited = IImplRep_;
20 Rep_ (
const Rep_&
from) =
default;
23 nonvirtual Rep_& operator= (
const Rep_&) =
delete;
30 return Memory::MakeSharedPtr<Rep_> (*
this);
37 virtual size_t size ()
const override
40 return fData_.size ();
42 virtual bool empty ()
const override
45 return fData_.empty ();
66 return Memory::MakeSharedPtr<Rep_> ();
72 shared_ptr<Rep_> result = Memory::MakeSharedPtr<Rep_> (*
this);
73 const IteratorRep_&
iteratorRep = Debug::UncheckedDynamicCast<const IteratorRep_&> (i->ConstGetRep ());
74 result->fData_.MoveIteratorHereAfterClone (&
iteratorRep.fIterator, &fData_);
81 fData_.push_front (
item);
82 fChangeCounts_.PerformedChange ();
91 const IteratorRep_&
iteratorRep = Debug::UncheckedDynamicCast<const IteratorRep_&> (i.ConstGetRep ());
92 if (
nextI !=
nullptr) {
96 fChangeCounts_.PerformedChange ();
97 if (
nextI !=
nullptr) {
104 const IteratorRep_&
iteratorRep = Debug::UncheckedDynamicCast<const IteratorRep_&> (i.ConstGetRep ());
105 if (
nextI ==
nullptr) {
107 fChangeCounts_.PerformedChange ();
111 fChangeCounts_.PerformedChange ();
117 using DataStructureImplType_ = DataStructures::LinkedList<value_type>;
118 using IteratorRep_ = Private::IteratorImplHelper_<value_type, DataStructureImplType_>;
121 DataStructureImplType_ fData_;
130 template <
typename T>
132 :
inherited{Memory::MakeSharedPtr<Rep_> ()}
134 AssertRepValidType_ ();
136 template <
typename T>
137 template <IInputIterator<T> ITERATOR_OF_ADDABLE>
142 AssertRepValidType_ ();
144 template <
typename T>
146 : Collection_LinkedList{}
149 AssertRepValidType_ ();
151#if !qCompilerAndStdLib_RequiresNotMatchInlineOutOfLineForTemplateClassBeingDefined_Buggy
152 template <
typename T>
153 template <IIterableOfTo<T> ITERABLE_OF_ADDABLE>
154 requires (not derived_from<remove_cvref_t<ITERABLE_OF_ADDABLE>, Collection_LinkedList<T>>)
156 : Collection_LinkedList{}
158 this->AddAll (forward<ITERABLE_OF_ADDABLE> (src));
159 AssertRepValidType_ ();
162 template <
typename T>
163 inline void Collection_LinkedList<T>::AssertRepValidType_ ()
const
166 typename inherited::template _SafeReadRepAccessor<Rep_> tmp{
this};
#define qStroika_Foundation_Debug_AssertionsChecked
The qStroika_Foundation_Debug_AssertionsChecked flag determines if assertions are checked and validat...
#define RequireNotNull(p)
#define qStroika_ATTRIBUTE_NO_UNIQUE_ADDRESS_VCFORCE
[[msvc::no_unique_address]] isn't always broken in MSVC. Annotate with this on things where its not b...
A Collection<T> is a container to manage an un-ordered collection of items, without equality defined ...
nonvirtual void AddAll(ITERATOR_OF_ADDABLE &&start, ITERATOR_OF_ADDABLE2 &&end)
nonvirtual void Update(const Iterator< value_type > &i, ArgByValueType< value_type > newValue, Iterator< value_type > *nextI=nullptr)
nonvirtual void Remove(ArgByValueType< value_type > item, EQUALS_COMPARER &&equalsComparer={})
Remove () the argument value (which must exist)
nonvirtual void Add(ArgByValueType< value_type > item)
Collection_LinkedList<T> is an LinkedList-based concrete implementation of the Collection<T> containe...
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...
nonvirtual void Apply(const function< void(ArgByValueType< T > item)> &doToElement, Execution::SequencePolicy seq=Execution::SequencePolicy::eDEFAULT) const
Run the argument function (or lambda) on each element of the container.
nonvirtual Iterator< T > Find(THAT_FUNCTION &&that, Execution::SequencePolicy seq=Execution::SequencePolicy::eDEFAULT) const
Run the argument bool-returning function (or lambda) on each element of the container,...
nonvirtual CONTAINER_OF_T As(CONTAINER_OF_T_CONSTRUCTOR_ARGS... args) const
nonvirtual size_t size() const
Returns the number of items contained.
nonvirtual bool empty() const
Returns true iff size() == 0.
static constexpr default_sentinel_t end() noexcept
Support for ranged for, and STL syntax in general.
nonvirtual Iterator< T > MakeIterator() const
Create an iterator object which can be used to traverse the 'Iterable'.
SequencePolicy
equivalent which of 4 types being used std::execution::sequenced_policy, parallel_policy,...