TPIE

2362a60
tpie::array_view< const T > Class Template Reference

Inherits tpie::array_view_base< const T >.

Public Types

typedef const T value_type
 Type of values contained in the array. More...
 

Public Member Functions

 array_view (array_view< T > o)
 
template<typename A >
 array_view (const std::vector< T, A > &v)
 
 array_view (const tpie::array< T > &v)
 
 array_view (const tpie::internal_vector< T > &v)
 
template<typename A >
 array_view (const std::vector< T, A > &v, size_t start, size_t end)
 
 array_view (const tpie::array< T > &v, size_t start, size_t end)
 
 array_view (const T *start, const T *end)
 
 array_view (const T *start, size_t size)
 
iterator find (size_t idx) const throw ()
 Return an iterator to the i'th element of the array. More...
 
const T & at (size_t i) const throw ()
 Return the element located at the given index. More...
 
bool empty () const
 Check if the array is empty. More...
 
size_t size () const
 Get number of elements in the array. More...
 
const T & operator[] (size_t i) const
 Return a reference to an array entry. More...
 
bool operator== (const array_view_base &other) const
 Check if the other array has the same elements in the same order as this. More...
 
bool operator!= (const array_view_base &other) const
 Check if the two arrays differ. More...
 
iterator begin () const
 Return an iterator to the beginning of the array. More...
 
iterator end () const
 Return an iterator to the end of the array. More...
 
const T & front () const
 Return the first element in the array. More...
 
const T & back () const
 Return the last element in the array. More...
 

Detailed Description

template<typename T>
class tpie::array_view< const T >

Definition at line 111 of file array_view.h.

Member Typedef Documentation

typedef const T tpie::array_view_base< const T >::value_type
inherited

Type of values contained in the array.

Definition at line 73 of file array_view_base.h.

Member Function Documentation

const T & tpie::array_view_base< const T >::at ( size_t  i) const
throw (
)
inlineinherited

Return the element located at the given index.

Parameters
iThe index of the element returned.

Definition at line 91 of file array_view_base.h.

References tpie::array_view_base< T >::find(), and tpie::array_view_base< T >::size().

91  {
92  assert(i < size());
93  return *find(i);
94  }
iterator find(size_t idx) const
Return an iterator to the i'th element of the array.
size_t size() const
Get number of elements in the array.
const T & tpie::array_view_base< const T >::back ( ) const
inlineinherited

Return the last element in the array.

Definition at line 167 of file array_view_base.h.

167 {return *(m_end-1);}
iterator tpie::array_view_base< const T >::begin ( ) const
inlineinherited

Return an iterator to the beginning of the array.

Returns
An iterator to the beginning of the array.

Definition at line 150 of file array_view_base.h.

150 {return iterator(m_start);}
bool tpie::array_view_base< const T >::empty ( ) const
inlineinherited

Check if the array is empty.

Returns
True if and only if size is 0.

Definition at line 101 of file array_view_base.h.

101 {return m_end == m_start;}
iterator tpie::array_view_base< const T >::end ( ) const
inlineinherited

Return an iterator to the end of the array.

Returns
An iterator to the end of the array.

Definition at line 157 of file array_view_base.h.

157 {return iterator(m_end);}
iterator tpie::array_view_base< const T >::find ( size_t  idx) const
throw (
)
inlineinherited

Return an iterator to the i'th element of the array.

Parameters
iThe index of the element we want an iterator to.
Returns
An iterator to the i'th element.

Definition at line 81 of file array_view_base.h.

References tpie::array_view_base< T >::size().

81  {
82  assert(idx <= size());
83  return iterator(m_start + idx);
84  }
size_t size() const
Get number of elements in the array.
const T & tpie::array_view_base< const T >::front ( ) const
inlineinherited

Return the first element in the array.

Definition at line 162 of file array_view_base.h.

162 {return *m_start;}
bool tpie::array_view_base< const T >::operator!= ( const array_view_base< const T > &  other) const
inlineinherited

Check if the two arrays differ.

Parameters
otherThe array to compare against.
Returns
false If they are equal otherwise true.

Definition at line 139 of file array_view_base.h.

References tpie::array_view_base< T >::at(), and tpie::array_view_base< T >::size().

139  {
140  if (size() != other.size()) return true;
141  for (size_t i=0; i< size(); ++i) if (at(i) != other.at(i)) return true;
142  return false;
143  }
const T & at(size_t i) const
Return the element located at the given index.
size_t size() const
Get number of elements in the array.
bool tpie::array_view_base< const T >::operator== ( const array_view_base< const T > &  other) const
inlineinherited

Check if the other array has the same elements in the same order as this.

Parameters
otherThe array to compare against.
Returns
True if they are equal, otherwise false.

Definition at line 127 of file array_view_base.h.

References tpie::array_view_base< T >::at(), and tpie::array_view_base< T >::size().

127  {
128  if (size() != other.size()) return false;
129  for (size_t i=0; i < size(); ++i) if (at(i) != other.at(i)) return false;
130  return true;
131  }
const T & at(size_t i) const
Return the element located at the given index.
size_t size() const
Get number of elements in the array.
const T & tpie::array_view_base< const T >::operator[] ( size_t  i) const
inlineinherited

Return a reference to an array entry.

Parameters
iThe index of the entry to return.
Returns
Reference to the entry.

Definition at line 115 of file array_view_base.h.

References tpie::array_view_base< T >::at(), and tpie::array_view_base< T >::size().

115  {
116  assert(i < size());
117  return at(i);
118  }
const T & at(size_t i) const
Return the element located at the given index.
size_t size() const
Get number of elements in the array.
size_t tpie::array_view_base< const T >::size ( ) const
inlineinherited

Get number of elements in the array.

Returns
Number of elements in the array.

Definition at line 107 of file array_view_base.h.

107 {return m_end - m_start;}

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