mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
express: add PointerToArray.count()
This commit is contained in:
parent
540122e703
commit
0281f306e1
@ -581,6 +581,19 @@ node_unref() const {
|
||||
return ((To *)(this->_void_ptr))->node_unref();
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the frequency at which the given element occurs in the vector.
|
||||
*/
|
||||
template<class Element>
|
||||
INLINE size_t PointerToArray<Element>::
|
||||
count(const Element &value) const {
|
||||
if ((this->_void_ptr) != nullptr) {
|
||||
return std::count(begin(), end(), value);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -1006,6 +1019,19 @@ node_unref() const {
|
||||
return ((To *)(this->_void_ptr))->node_unref();
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the frequency at which the given element occurs in the vector.
|
||||
*/
|
||||
template<class Element>
|
||||
INLINE size_t ConstPointerToArray<Element>::
|
||||
count(const Element &value) const {
|
||||
if ((this->_void_ptr) != nullptr) {
|
||||
return std::count(begin(), end(), value);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -112,6 +112,8 @@ PUBLISHED:
|
||||
INLINE int get_ref_count() const;
|
||||
INLINE int get_node_ref_count() const;
|
||||
|
||||
INLINE size_t count(const Element &) const;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags));
|
||||
EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
|
||||
@ -214,6 +216,8 @@ public:
|
||||
INLINE void node_ref() const;
|
||||
INLINE bool node_unref() const;
|
||||
|
||||
INLINE size_t count(const Element &) const;
|
||||
|
||||
// Reassignment is by pointer, not memberwise as with a vector.
|
||||
INLINE PointerToArray<Element> &
|
||||
operator = (ReferenceCountedVector<Element> *ptr);
|
||||
@ -266,6 +270,8 @@ PUBLISHED:
|
||||
INLINE int get_ref_count() const;
|
||||
INLINE int get_node_ref_count() const;
|
||||
|
||||
INLINE size_t count(const Element &) const;
|
||||
|
||||
#ifdef HAVE_PYTHON
|
||||
EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
|
||||
EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
|
||||
@ -341,6 +347,8 @@ PUBLISHED:
|
||||
INLINE void node_ref() const;
|
||||
INLINE bool node_unref() const;
|
||||
|
||||
INLINE size_t count(const Element &) const;
|
||||
|
||||
// Reassignment is by pointer, not memberwise as with a vector.
|
||||
INLINE ConstPointerToArray<Element> &
|
||||
operator = (ReferenceCountedVector<Element> *ptr);
|
||||
|
@ -1706,3 +1706,19 @@ INLINE_LINMATH int FLOATNAME(UnalignedLMatrix4)::
|
||||
get_num_components() const {
|
||||
return 16;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE_LINMATH bool FLOATNAME(UnalignedLMatrix4)::
|
||||
operator == (const FLOATNAME(UnalignedLMatrix4) &other) const {
|
||||
return memcmp(get_data(), other.get_data(), sizeof(FLOATTYPE) * 16) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE_LINMATH bool FLOATNAME(UnalignedLMatrix4)::
|
||||
operator != (const FLOATNAME(UnalignedLMatrix4) &other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
@ -345,6 +345,9 @@ PUBLISHED:
|
||||
INLINE_LINMATH const FLOATTYPE *get_data() const;
|
||||
INLINE_LINMATH int get_num_components() const;
|
||||
|
||||
INLINE_LINMATH bool operator == (const FLOATNAME(UnalignedLMatrix4) &other) const;
|
||||
INLINE_LINMATH bool operator != (const FLOATNAME(UnalignedLMatrix4) &other) const;
|
||||
|
||||
public:
|
||||
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 4, 4) UMatrix4;
|
||||
UMatrix4 _m;
|
||||
|
@ -971,3 +971,22 @@ INLINE_LINMATH const FLOATTYPE *FLOATNAME(UnalignedLVecBase4)::
|
||||
get_data() const {
|
||||
return &_v(0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE_LINMATH bool FLOATNAME(UnalignedLVecBase4)::
|
||||
operator == (const FLOATNAME(UnalignedLVecBase4) &other) const {
|
||||
return (_v(0) == other._v(0) &&
|
||||
_v(1) == other._v(1) &&
|
||||
_v(2) == other._v(2) &&
|
||||
_v(3) == other._v(3));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE_LINMATH bool FLOATNAME(UnalignedLVecBase4)::
|
||||
operator != (const FLOATNAME(UnalignedLVecBase4) &other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
@ -243,6 +243,9 @@ PUBLISHED:
|
||||
INLINE_LINMATH const FLOATTYPE *get_data() const;
|
||||
CONSTEXPR static int get_num_components() { return 4; }
|
||||
|
||||
INLINE_LINMATH bool operator == (const FLOATNAME(UnalignedLVecBase4) &other) const;
|
||||
INLINE_LINMATH bool operator != (const FLOATNAME(UnalignedLVecBase4) &other) const;
|
||||
|
||||
public:
|
||||
typedef FLOATTYPE numeric_type;
|
||||
typedef UNALIGNED_LINMATH_MATRIX(FLOATTYPE, 1, 4) UVector4;
|
||||
|
Loading…
x
Reference in New Issue
Block a user