AGX Dynamics  2.37.3.2
IndexListRange.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_INDEXLISTRANGE_H
18 #define AGX_INDEXLISTRANGE_H
19 
20 #include <agxData/Array.h>
21 
22 namespace agx
23 {
24  template< typename T>
26  {
27  public:
28  typedef T Type;
29  typedef const T* iterator;
30  public:
31  IndexListRange( const agxData::Array<T>& indexList, IndexRange range );
32 
33  iterator begin() const;
34  iterator end() const;
35 
36  size_t size() const;
37 
38  const T& operator[]( size_t index ) const;
39 
40  private:
41  const agxData::Array<T>& m_indexList;
42 
43  IndexListRange<T>& operator=(const IndexListRange<T>&) { agxAbort(); }
44  IndexRange m_range;
45  };
46 
47 
48  template< typename T>
50  m_indexList( indexList ) , m_range( range )
51  {
52  agxAssert( range.end() <= indexList.size() );
53  }
54 
55  template< typename T>
57  {
58  return &m_indexList[ m_range.begin() ];
59  }
60 
61  template< typename T>
63  {
64  // Special handling when the range extends to the end of the Array since
65  // we can't take the address of the 'end' element.
66  return m_range.end() == m_indexList.size() ? m_indexList.end() : &m_indexList[ m_range.end() ];
67  }
68 
69  template< typename T>
70  size_t IndexListRange<T>::size() const
71  {
72  return m_range.size();
73  }
74 
75  template< typename T>
76  const T& IndexListRange<T>::operator[] ( size_t index ) const
77  {
78  return m_indexList[ m_range[index] ];
79  }
80 }
81 
82 
83 
84 #endif
size_t size() const
Definition: Buffer.h:708
IndexListRange(const agxData::Array< T > &indexList, IndexRange range)
#define agxAbort()
Definition: debug.h:164
Type-specific Array used for fast access into the data held by a Buffer.
Definition: agxData.h:30
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
#define agxAssert(expr)
Definition: debug.h:143
iterator end() const
const T & operator[](size_t index) const
T size() const
Definition: IndexRange.h:168
iterator begin() const
size_t size() const