Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
usShrinkableVector.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef USSHRINKABLEVECTOR_H
14 #define USSHRINKABLEVECTOR_H
15 
16 #include <usGlobalConfig.h>
17 
18 #include <vector>
19 
20 namespace us {
21 
28 template<class E>
30 {
31 private:
32  static std::vector<E> emptyVector;
33 
34 public:
35 
36  typedef std::vector<E> container_type;
37  typedef typename container_type::iterator iterator;
38  typedef typename container_type::const_iterator const_iterator;
39  typedef typename container_type::size_type size_type;
40  typedef typename container_type::reference reference;
41  typedef typename container_type::const_reference const_reference;
42 
44  : container(emptyVector)
45  {
46  }
47 
49  {
50  return container.begin();
51  }
52 
54  {
55  return container.begin();
56  }
57 
59  {
60  return container.end();
61  }
62 
64  {
65  return container.end();
66  }
67 
69  {
70  return container.front();
71  }
72 
74  {
75  return container.front();
76  }
77 
79  {
80  return container.back();
81  }
82 
84  {
85  return container.back();
86  }
87 
89  {
90  return container.erase(pos);
91  }
92 
94  {
95  return container.erase(first, last);
96  }
97 
98  void pop_back()
99  {
100  container.pop_back();
101  }
102 
103  bool empty() const
104  {
105  return container.empty();
106  }
107 
108  void clear()
109  {
110  container.clear();
111  }
112 
113  size_type size() const
114  {
115  return container.size();
116  }
117 
119  {
120  return container.at(pos);
121  }
122 
124  {
125  return container.at(pos);
126  }
127 
129  {
130  return container[i];
131  }
132 
134  {
135  return container[i];
136  }
137 
138 private:
139 
140  friend class ModuleHooks;
141  friend class ServiceHooks;
142 
143  ShrinkableVector(container_type& container)
144  : container(container)
145  {}
146 
147  container_type& container;
148 };
149 
150 template<class E>
151 std::vector<E> ShrinkableVector<E>::emptyVector;
152 
153 }
154 
155 #endif // USSHRINKABLEVECTOR_H
A std::vector style container allowing query and removal operations only.
const_reference operator[](size_type i) const
container_type::reference reference
container_type::const_reference const_reference
std::vector< E > container_type
container_type::size_type size_type
const_reference at(size_type pos) const
reference at(size_type pos)
const_iterator begin() const
const_reference front() const
reference operator[](size_type i)
size_type size() const
const_iterator end() const
const_reference back() const
iterator erase(iterator first, iterator last)
container_type::const_iterator const_iterator
iterator erase(iterator pos)
container_type::iterator iterator