#pragma once #include #include #include "XDWExclusiveHolder.tlh" #include "XDWExclusiveHolder.tli" #include "Iterator.tlh" //----------------------------------------------------------------------------- // ExclusiveList //----------------------------------------------------------------------------- template class ExclusiveList : public XDWExclusiveHolder > { typedef XDWExclusiveHolder > inherited; public: using container = std::list ; using reference = typename std::list ::reference; using const_reference = typename std::list ::const_reference; using const_iterator = typename std::list ::const_iterator; public: ExclusiveList () { Attach (new std::list ()); } public: bool IsEmpty () const { LockHolder Lock (this); if (m_pObject == NULL) return true; return m_pObject->empty (); } template void LockForEach (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter ++) { action (Iter ()); } } template int LockForEachIf (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter ++) { if (! action (Iter ())) return Iter.Index (); } return -1; } }; //----------------------------------------------------------------------------- // ExclusiveVector //----------------------------------------------------------------------------- template class ExclusiveVector : public XDWExclusiveHolder > { typedef XDWExclusiveHolder > inherited; public: using container = std::vector ; using reference = typename std::vector ::reference; using const_reference = typename std::vector ::const_reference; using const_iterator = typename std::vector ::const_iterator; public: ExclusiveVector () { Attach (new std::vector ()); } public: bool IsEmpty () const { LockHolder Lock (this); if (m_pObject == NULL) return true; return m_pObject->empty (); } template void LockForEach (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter ++ ) { action (Iter ()); } } template int LockForEachIf (Action action) { LockHolder holder (this); for (auto Iter = Iterator::From (holder.As ()); Iter; Iter++) { if (! action (Iter ())) return Iter.Index (); } return -1; } };