Main MRPT website > C++ reference for MRPT 1.5.7
xsushortvector.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef XSUSHORTVECTOR_H
10 #define XSUSHORTVECTOR_H
11 
12 #ifndef __cplusplus
13 #define XSUSHORTVECTOR_INITIALIZER {{0,0,0}}
14 #else
15 #include "xstypedefs.h"
16 #endif
17 
18 /*! \brief A vector containing 3 short values. */
20 #ifdef __cplusplus
21  //! \brief Constructor that creates the vector with all components set to 0
22  inline XsUShortVector()
23  {
24  m_data[0] = 0;
25  m_data[1] = 0;
26  m_data[2] = 0;
27  }
28 
29  //! \brief Constructor that creates the vector with all components set to given values \a v1 \a v2 and \a v3
30  inline XsUShortVector(unsigned short v1, unsigned short v2, unsigned short v3)
31  {
32  m_data[0] = v1;
33  m_data[1] = v2;
34  m_data[2] = v3;
35  }
36 
37  //! \brief Constructor that creates the vector with all components set to values in array \a a
38  inline explicit XsUShortVector(const unsigned short* a)
39  {
40  m_data[0] = a[0];
41  m_data[1] = a[1];
42  m_data[2] = a[2];
43  }
44 
45  //! \brief Constructor that creates the vector and initializes it with data from the \a other vector
46  inline XsUShortVector(const XsUShortVector& other)
47  {
48  m_data[0] = other.m_data[0];
49  m_data[1] = other.m_data[1];
50  m_data[2] = other.m_data[2];
51  }
52 
53  //! \brief Assignment operator copies the data from the \a other vector to this vector
54  inline const XsUShortVector& operator = (const XsUShortVector& other)
55  {
56  if (this != &other)
57  {
58  m_data[0] = other.m_data[0];
59  m_data[1] = other.m_data[1];
60  m_data[2] = other.m_data[2];
61  }
62  return *this;
63  }
64 
65  //! \brief Comparison operator, returns true if the contents of the \a other vector match those of this vector
66  inline bool operator == (const XsUShortVector& other) const
67  {
68  return m_data[0] == other.m_data[0] &&
69  m_data[1] == other.m_data[1] &&
70  m_data[2] == other.m_data[2];
71  }
72 
73  //! \brief Return the size of the vector (always 3)
74  inline XsSize size() const
75  {
76  return 3;
77  }
78 
79  //! \brief Return a value from the vector (needed to allow generated C# access to these elements)
80  inline unsigned short at(int index)
81  {
82  return m_data[index];
83  }
84 
85  //! \brief Returns the \a index'th item in the vector
86  inline unsigned short operator[](XsSize index) const
87  {
88  assert(index < 3);
89  return m_data[index];
90  }
91 
92  //! \brief Returns a reference the \a index'th item in the vector
93  inline unsigned short& operator[](XsSize index)
94  {
95  assert(index < 3);
96  return m_data[index]; //lint !e1536
97  }
98 private:
99 #endif
100 
101  unsigned short m_data[3]; //!< vector component storage
102 };
103 
105 
106 #endif // XSUSHORTVECTOR_H
bool operator==(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
struct XsUShortVector XsUShortVector
A vector containing 3 short values.
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:17
GLuint index
Definition: glext.h:3891
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn&#39;t exist already.
Definition: ts_hash_map.h:123
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:3924
GLfloat GLfloat v1
Definition: glext.h:3922
GLfloat GLfloat GLfloat v2
Definition: glext.h:3923
GLsizeiptr size
Definition: glext.h:3779
GLubyte GLubyte GLubyte a
Definition: glext.h:5575
unsigned short m_data[3]
vector component storage



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019