AGXDynamics
2.35.0.2
IndexListRange.h
Go to the documentation of this file.
1
/*
2
Copyright 2007-2022. 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>
25
class
IndexListRange
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>
49
IndexListRange<T>::IndexListRange
(
const
agxData::Array<T>
& indexList,
IndexRange
range ) :
50
m_indexList( indexList ) , m_range( range )
51
{
52
agxAssert
( range.
end
() <= indexList.size() );
53
}
54
55
template
<
typename
T>
56
typename
IndexListRange<T>::iterator
IndexListRange<T>::begin
()
const
57
{
58
return
&m_indexList[ m_range.begin() ];
59
}
60
61
template
<
typename
T>
62
typename
IndexListRange<T>::iterator
IndexListRange<T>::end
()
const
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
agx::IndexListRange::end
iterator end() const
Definition:
IndexListRange.h:62
agx::IndexListRange::Type
T Type
Definition:
IndexListRange.h:28
agx::IndexListRange::iterator
const typedef T * iterator
Definition:
IndexListRange.h:29
agxAssert
#define agxAssert(expr)
Definition:
debug.h:143
Array.h
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition:
AddedMassInteraction.h:22
agxData::Array
Type-specific Array used for fast access into the data held by a Buffer.
Definition:
agxData.h:30
agx::IndexRangeT< agx::UInt >
agx::IndexListRange::IndexListRange
IndexListRange(const agxData::Array< T > &indexList, IndexRange range)
Definition:
IndexListRange.h:49
agxAbort
#define agxAbort()
Definition:
debug.h:164
agx::IndexListRange::size
size_t size() const
Definition:
IndexListRange.h:70
agx::IndexListRange
Definition:
IndexListRange.h:25
agx::IndexRangeT::end
T & end()
Definition:
IndexRange.h:217
agx::IndexListRange::operator[]
const T & operator[](size_t index) const
Definition:
IndexListRange.h:76
agx::IndexListRange::begin
iterator begin() const
Definition:
IndexListRange.h:56
include
agx
IndexListRange.h
Generated on Mon Jan 30 2023 15:44:13 for AGXDynamics by
1.8.17