Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
vector0.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file utility/vector0.hh
11 /// @brief vector0: std::vector with assert-checked bounds
12 /// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
13 
14 
15 #ifndef INCLUDED_utility_vector0_HH
16 #define INCLUDED_utility_vector0_HH
17 
18 
19 // Unit headers
20 #include <utility/vector0.fwd.hh>
21 
22 // Package headers
23 #include <utility/vectorL.hh>
24 
25 
26 namespace utility {
27 
28 
29 /// @brief std::vector with assert-checked bounds
30 //
31 // std::vector with assert-checked bounds in operator[] and a few extras
32 //
33 // Can construct and assign from std::vector and swap with std::vector
34 //
35 // Can compare with std::vector
36 //
37 // Can explicitly convert to std::vector
38 //
39 // Public inheritance from concrete vectorL template is safe here
40 template< typename T, typename A >
41 class vector0 :
42  public vectorL< 0, T, A >
43 {
44 
45 private: // Types
46 
47 
49 
50 
51 public: // Types
52 
53 
54  // STL/boost style
55  typedef typename super::value_type value_type;
56  typedef typename super::reference reference;
58  typedef typename super::pointer pointer;
60  typedef typename super::iterator iterator;
64  typedef typename super::size_type size_type;
67  typedef typename super::index_type index_type;
68  typedef typename super::ssize_type ssize_type;
69 
70  // Project style
71  typedef typename super::Value Value;
72  typedef typename super::Reference Reference;
74  typedef typename super::Pointer Pointer;
76  typedef typename super::Iterator Iterator;
80  typedef typename super::Size Size;
81  typedef typename super::Difference Difference;
82  typedef typename super::Allocator Allocator;
83  typedef typename super::Index Index;
84  typedef typename super::SSize SSize;
85 
86 
87 public: // Methods: imports
88 
89 
90  using super::assign;
91  using super::at;
92  using super::back;
93  using super::begin;
94  using super::capacity;
95  using super::clear;
96  using super::empty;
97  using super::end;
98  using super::erase;
99  using super::front;
100  using super::get_allocator;
101  using super::insert;
102  using super::max_size;
103  using super::operator [];
104  using super::pop_back;
105  using super::push_back;
106  using super::rbegin;
107  using super::rend;
108  using super::reserve;
109  using super::resize;
110  using super::size;
111  using super::swap;
112 
113 
114 public: // Creation
115 
116 
117  /// @brief Default constructor
118  inline
119  explicit
120  vector0( allocator_type const & alloc = allocator_type() ) :
121  super( alloc )
122  {}
123 
124 
125  /// @brief Copy constructor
126  inline
127  vector0( vector0 const & v ) :
128  super( v )
129  {}
130 
131 
132  /// @brief Assignable copy constructor
133  template< ssize_type L_, typename T_, typename A_ >
134  inline
136  super( v.begin(), v.end() )
137  {}
138 
139 
140  /// @brief std::vector constructor
141  inline
142  explicit
143  vector0( super const & v ) :
144  super( v )
145  {}
146 
147 
148  /// @brief Assignable std::vector constructor
149  template< typename T_, typename A_ >
150  inline
151  explicit
152  vector0( std::vector< T_, A_ > const & v ) :
153  super( v.begin(), v.end() )
154  {}
155 
156 
157  /// @brief Size constructor
158  inline
159  explicit
160  vector0( size_type const num ) :
161  super( num )
162  {}
163 
164 
165  /// @brief Uniform value constructor
166  inline
168  size_type const num,
169  value_type const & value,
170  allocator_type const & alloc = allocator_type()
171  ) :
172  super( num, value, alloc )
173  {}
174 
175 
176  /// @brief Iterator range constructor
177  template< typename InputIterator >
178  inline
180  InputIterator const beg,
181  InputIterator const end,
182  allocator_type const & alloc = allocator_type()
183  ) :
184  super( beg, end, alloc )
185  {}
186 
187 
188  /// @brief Destructor
189  inline
190  virtual
192  {}
193 
194 
195 public: // Assignment
196 
197 
198  /// @brief Copy assignment
199  inline
200  vector0 &
201  operator =( vector0 const & v )
202  {
203  if ( this != &v ) {
204  super::operator =( v );
205  }
206  return *this;
207  }
208 
209 
210  /// @brief Assignable copy assignment
211  template< ssize_type L_, typename T_, typename A_ >
212  inline
213  vector0 &
215  {
216  super::assign( v.begin(), v.end() );
217  return *this;
218  }
219 
220 
221  /// @brief std::vector assignment
222  inline
223  vector0 &
224  operator =( super const & v )
225  {
226  super::operator =( v );
227  return *this;
228  }
229 
230 
231  /// @brief Assignable std::vector assignment
232  template< typename T_, typename A_ >
233  inline
234  vector0 &
235  operator =( std::vector< T_, A_ > const & v )
236  {
237  super::assign( v.begin(), v.end() );
238  return *this;
239  }
240 
241 
242 }; // vector0
243 
244 
245 } // namespace utility
246 
247 
248 // bool specialization
249 #include <utility/vector0_bool.hh>
250 
251 
252 #endif // INCLUDED_utility_vector0_HH
super::const_iterator const_iterator
Definition: vectorL.hh:74
vector0(vector0 const &v)
Copy constructor.
Definition: vector0.hh:127
super::ConstReverseIterator ConstReverseIterator
Definition: vector0.hh:79
super::reference reference
Definition: vector0.hh:56
super::ConstPointer ConstPointer
Definition: vector0.hh:75
super::reverse_iterator reverse_iterator
Definition: vectorL.hh:75
super::Index Index
Definition: vector0.hh:83
::platform::SSize ssize_type
Definition: vectorL.hh:81
dictionary size
Definition: amino_acids.py:44
super::ConstReference ConstReference
Definition: vector0.hh:73
vector0(allocator_type const &alloc=allocator_type())
Default constructor.
Definition: vector0.hh:120
std::vector with assert-checked bounds
Definition: vector0.fwd.hh:44
super::const_reverse_iterator const_reverse_iterator
Definition: vectorL.hh:76
super::allocator_type allocator_type
Definition: vector0.hh:66
void swap(vectorL &v)
swap( vectorL )
Definition: vectorL.hh:614
super::SSize SSize
Definition: vector0.hh:84
super::ssize_type ssize_type
Definition: vector0.hh:68
super::allocator_type Allocator
Definition: vectorL.hh:98
utility::keys::lookup::end< KeyType > const end
vector0(vectorL< L_, T_, A_ > const &v)
Assignable copy constructor.
Definition: vector0.hh:135
vector0(super const &v)
std::vector constructor
Definition: vector0.hh:143
virtual ~vector0()
Destructor.
Definition: vector0.hh:191
super::Allocator Allocator
Definition: vector0.hh:82
super::const_reference const_reference
Definition: vectorL.hh:70
super::const_iterator const_iterator
Definition: vector0.hh:61
vector0(size_type const num, value_type const &value, allocator_type const &alloc=allocator_type())
Uniform value constructor.
Definition: vector0.hh:167
super::Iterator Iterator
Definition: vector0.hh:76
super::const_reference ConstReference
Definition: vectorL.hh:86
super::allocator_type allocator_type
Definition: vectorL.hh:79
super::reverse_iterator ReverseIterator
Definition: vectorL.hh:91
super::const_iterator ConstIterator
Definition: vectorL.hh:90
vector0: std::vector with assert-checked bounds: bool specialization
super::difference_type difference_type
Definition: vector0.hh:65
super::difference_type difference_type
Definition: vectorL.hh:78
super::pointer pointer
Definition: vector0.hh:58
vector0(size_type const num)
Size constructor.
Definition: vector0.hh:160
vector0(std::vector< T_, A_ > const &v)
Assignable std::vector constructor.
Definition: vector0.hh:152
member1 value
Definition: Tag.cc:296
super::difference_type Difference
Definition: vectorL.hh:97
super::Value Value
Definition: vector0.hh:71
super::const_pointer ConstPointer
Definition: vectorL.hh:88
super::const_reverse_iterator const_reverse_iterator
Definition: vector0.hh:63
super::value_type value_type
Definition: vector0.hh:55
vectorL: std::vector with L-based indexing
super::value_type value_type
Definition: vectorL.hh:68
super::const_pointer const_pointer
Definition: vectorL.hh:72
vector0(InputIterator const beg, InputIterator const end, allocator_type const &alloc=allocator_type())
Iterator range constructor.
Definition: vector0.hh:179
super::Size Size
Definition: vector0.hh:80
super::ReverseIterator ReverseIterator
Definition: vector0.hh:78
super::size_type size_type
Definition: vector0.hh:64
vectorL< 0, T, A > super
Definition: vector0.hh:48
const_reference at(index_type const i) const
vectorL.at( i ) const
Definition: vectorL.hh:388
utility::keys::lookup::begin< KeyType > const begin
super::Reference Reference
Definition: vector0.hh:72
super::index_type index_type
Definition: vector0.hh:67
super::Pointer Pointer
Definition: vector0.hh:74
super::iterator iterator
Definition: vector0.hh:60
super::Difference Difference
Definition: vector0.hh:81
vectorL & operator=(vectorL const &v)
Copy assignment.
Definition: vectorL.hh:215
utility::vector0 forward declarations
super::reverse_iterator reverse_iterator
Definition: vector0.hh:62
super::const_reverse_iterator ConstReverseIterator
Definition: vectorL.hh:92
super::const_reference const_reference
Definition: vector0.hh:57
super::ConstIterator ConstIterator
Definition: vector0.hh:77
super::const_pointer const_pointer
Definition: vector0.hh:59
vector0 & operator=(vector0 const &v)
Copy assignment.
Definition: vector0.hh:201