21 #ifndef otbObjectList_hxx
22 #define otbObjectList_hxx
32 template <
class TObject>
41 template <
class TObject>
44 m_InternalContainer.reserve(size);
51 template <
class TObject>
54 return m_InternalContainer.capacity();
61 template <
class TObject>
64 return m_InternalContainer.size();
71 template <
class TObject>
74 m_InternalContainer.resize(size);
81 template <
class TObject>
84 m_InternalContainer.push_back(element);
92 template <
class TObject>
95 if (m_InternalContainer.size() > 0)
97 m_InternalContainer.pop_back();
108 template <
class TObject>
111 if (index >= m_InternalContainer.size())
113 itkExceptionMacro(<<
"Impossible to SetNthElement with the index element " << index <<
"; this element don't exist, the size of the list is "
114 << m_InternalContainer.size() <<
".");
116 m_InternalContainer[index] = element;
125 template <
class TObject>
128 if (index >= m_InternalContainer.size())
130 itkExceptionMacro(<<
"Impossible to SetNthElement with the index element " << index <<
"; this element don't exist, the size of the list is "
131 << m_InternalContainer.size() <<
".");
133 m_InternalContainer[index] =
const_cast<ObjectType*
>(element);
143 template <
class TObject>
146 if (index >= m_InternalContainer.size())
148 itkExceptionMacro(<<
"Impossible to GetNthElement with the index element " << index <<
"; this element don't exist, the size of the list is "
149 << m_InternalContainer.size() <<
".");
151 return m_InternalContainer[index];
155 template <
class TObject>
159 return dynamic_cast<itk::DataObject*
>(GetNthElement(index).GetPointer());
167 template <
class TObject>
170 return m_InternalContainer.front();
176 template <
class TObject>
179 return m_InternalContainer.back();
186 template <
class TObject>
189 if (index >= m_InternalContainer.size())
191 itkExceptionMacro(<<
"Impossible to erase the index element " << index <<
"; the size of the list is " << m_InternalContainer.size() <<
".");
193 m_InternalContainer.erase(m_InternalContainer.begin() + index);
200 template <
class TObject>
203 m_InternalContainer.clear();
211 template <
class TObject>
214 Iterator iter(m_InternalContainer.insert(position.GetIter(), element));
223 template <
class TObject>
226 ReverseIterator iter((
typename InternalContainerType::reverse_iterator)(m_InternalContainer.insert(position.GetIter().base(), element)));
236 template <
class TObject>
239 Iterator iter(m_InternalContainer.begin());
247 template <
class TObject>
250 ConstIterator iter(m_InternalContainer.begin());
258 template <
class TObject>
261 ReverseIterator iter(m_InternalContainer.rbegin());
269 template <
class TObject>
272 ReverseConstIterator iter(m_InternalContainer.rbegin());
280 template <
class TObject>
283 Iterator iter(m_InternalContainer.end());
291 template <
class TObject>
294 ConstIterator iter(m_InternalContainer.end());
302 template <
class TObject>
305 ReverseIterator iter(m_InternalContainer.rend());
313 template <
class TObject>
316 ReverseConstIterator iter(m_InternalContainer.rend());
325 template <
class TObject>
328 m_InternalContainer.erase(begin.GetIter(), end.GetIter());
336 template <
class TObject>
339 m_InternalContainer.erase(loc.GetIter());
345 template <
class TObject>
348 Superclass::PrintSelf(os, indent);
349 os << indent <<
"Size: " << m_InternalContainer.size() << std::endl;
350 os << indent <<
"List contains : " << std::endl;
351 ConstIterator iter = this->Begin();
352 while (iter != this->End())
354 os << indent.GetNextIndent() << iter.Get().GetPointer() << std::endl;
355 os << indent.GetNextIndent() << iter.Get() << std::endl;