CrystalSpace

Public API Reference

iArrayReadOnly< T > Struct Template Reference
[Containers]

Array interface template, read-only. More...

#include <iutil/array.h>

Inheritance diagram for iArrayReadOnly< T >:

List of all members.

Public Member Functions

virtual size_t Find (T const &which) const =0
 Find an element in array.
virtual T const & Get (size_t n) const =0
 Get an element (const).
virtual void GetAll (T *dest) const =0
 Copy all elements to dest.
virtual size_t GetIndex (const T *which) const =0
 Given a pointer to an element in the array this function will return the index.
virtual size_t GetSize () const =0
 Return the number of elements in the array.
virtual bool IsEmpty () const =0
 Return true if the array is empty.
virtual T const & Top () const =0
 Return the top element but do not remove it (const).

Detailed Description

template<typename T>
struct iArrayReadOnly< T >

Array interface template, read-only.

The functions provided allow to enumerate and read all elements of an array, but no modifications are permitted.

This template can't be used as-is in another interface; rather, it must be derived and specialized before it can be used. Example:

 struct csFoo { ... };
 struct iFooArray : public iArrayReadOnly<csFoo>
 {
   SCF_IARRAYREADONLY_INTERFACE(iFooArray);
 };

Standard implementations for this interface are scfArray, scfArrayWrap and scfArrayWrapConst.

Definition at line 50 of file array.h.


Member Function Documentation

template<typename T>
virtual size_t iArrayReadOnly< T >::Find ( T const &  which  )  const [pure virtual]

Find an element in array.

Returns:
csArrayItemNotFound if not found, else the item index.
Warning:
Performs a slow linear search.
template<typename T>
virtual T const& iArrayReadOnly< T >::Get ( size_t  n  )  const [pure virtual]

Get an element (const).

template<typename T>
virtual void iArrayReadOnly< T >::GetAll ( T *  dest  )  const [pure virtual]

Copy all elements to dest.

dest should be large enough to take all elements contained in the array.

template<typename T>
virtual size_t iArrayReadOnly< T >::GetIndex ( const T *  which  )  const [pure virtual]

Given a pointer to an element in the array this function will return the index.

Note that this function does not check if the returned index is actually valid. The caller of this function is responsible for testing if the returned index is within the bounds of the array.

template<typename T>
virtual size_t iArrayReadOnly< T >::GetSize (  )  const [pure virtual]

Return the number of elements in the array.

template<typename T>
virtual bool iArrayReadOnly< T >::IsEmpty (  )  const [pure virtual]

Return true if the array is empty.

Remarks:
Rigidly equivalent to return GetSize() == 0, but more idiomatic.
template<typename T>
virtual T const& iArrayReadOnly< T >::Top (  )  const [pure virtual]

Return the top element but do not remove it (const).


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

Generated for Crystal Space 2.0 by doxygen 1.6.1