CSEngine
Loading...
Searching...
No Matches
CSE::SContainerList< T > Class Template Reference
Inheritance diagram for CSE::SContainerList< T >:
CSE::SIContainer< std::list< T >, T, int >

Public Member Functions

void Register (T object) override
 
void Remove (T object) override
 
Get (int index) const override
 
std::list< T > GetAll () const override
 
int GetID (T object) const override
 
int GetSize () const override
 

Protected Attributes

std::list< T > m_objects
 
int m_size = 0
 

Detailed Description

template<class T>
class CSE::SContainerList< T >

Definition at line 10 of file SContainerList.h.

Member Function Documentation

◆ Get()

template<class T >
T CSE::SContainerList< T >::Get ( int  index) const
inlineoverridevirtual

Implements CSE::SIContainer< std::list< T >, T, int >.

Definition at line 27 of file SContainerList.h.

27 {
28 if (index < 0 || index > m_size || m_size < 1) return nullptr;
29 auto iter = m_objects.begin();
30 std::advance(iter, index);
31 return *iter;
32 }

◆ GetAll()

template<class T >
std::list< T > CSE::SContainerList< T >::GetAll ( ) const
inlineoverridevirtual

Implements CSE::SIContainer< std::list< T >, T, int >.

Definition at line 34 of file SContainerList.h.

34 {
35 return m_objects;
36 }

◆ GetID()

template<class T >
int CSE::SContainerList< T >::GetID ( object) const
inlineoverridevirtual

Implements CSE::SIContainer< std::list< T >, T, int >.

Definition at line 38 of file SContainerList.h.

38 {
39 auto it = std::find(m_objects.begin(), m_objects.end(), object);
40 if (it == m_objects.end())
41 return -1;
42 else
43 return std::distance(m_objects.begin(), it);
44 }

◆ GetSize()

template<class T >
int CSE::SContainerList< T >::GetSize ( ) const
inlineoverridevirtual

Implements CSE::SIContainer< std::list< T >, T, int >.

Definition at line 46 of file SContainerList.h.

46 {
47 return m_size;
48 }

◆ Register()

template<class T >
void CSE::SContainerList< T >::Register ( object)
inlineoverridevirtual

Implements CSE::SIContainer< std::list< T >, T, int >.

Definition at line 15 of file SContainerList.h.

15 {
16 m_objects.push_back(object);
17 m_size++;
18 }

◆ Remove()

template<class T >
void CSE::SContainerList< T >::Remove ( object)
inlineoverridevirtual

Implements CSE::SIContainer< std::list< T >, T, int >.

Definition at line 20 of file SContainerList.h.

20 {
21// auto iObj = std::find(m_objects.begin(), m_objects.end(), object);
22// if (iObj != m_objects.end()) {
23 m_objects.remove(object);
24// }
25 }

Member Data Documentation

◆ m_objects

template<class T >
std::list<T> CSE::SContainerList< T >::m_objects
protected

Definition at line 52 of file SContainerList.h.

◆ m_size

template<class T >
int CSE::SContainerList< T >::m_size = 0
protected

Definition at line 53 of file SContainerList.h.


The documentation for this class was generated from the following file: