37#if !defined(LIBCOYOTL_ARRAY_H)
38#define LIBCOYOTL_ARRAY_H
42#pragma warning(disable : 4290 4101)
51#if defined(LIBCOYOTL_BOUNDS_CHECKING)
54#define LIBCOYOTL_ARRAY_EXCEPTIONS validation_error<size_t>
55#define LIBCOYOTL_ARRAY_CHECK_INDEX(n) validate_less(n,m_size,LIBCOYOTL_LOCATION);
57#define LIBCOYOTL_ARRAY_EXCEPTIONS
58#define LIBCOYOTL_ARRAY_CHECK_INDEX(n)
71 template <
typename Type>
113 array(
size_t a_length);
122 array(
size_t a_length,
const Type & a_init_value);
138 array(
size_t a_length,
const Type * a_carray);
155 array & operator = (const
array<Type> & a_source) throw();
163 array & operator = (const Type & a_value) throw();
171 array & operator = (const Type * a_carray) throw();
180 const Type *
c_array() const throw();
188 Type & operator [] (
size_t n) throw(LIBCOYOTL_ARRAY_EXCEPTIONS);
196 Type operator [] (
size_t n) const throw(LIBCOYOTL_ARRAY_EXCEPTIONS);
269 bool operator == (const
array<Type> & a_comparand) const throw();
278 bool operator != (const
array<Type> & a_comparand) const throw();
287 bool operator < (const
array<Type> & a_comparand) const throw();
296 bool operator <= (const
array<Type> & a_comparand) const throw();
305 bool operator > (const
array<Type> & a_comparand) const throw();
314 bool operator >= (const
array<Type> & a_comparand) const throw();
322 void swap(
array<Type> & a_source) throw();
330 size_t size() const throw();
346 bool empty() const throw();
357 void assign_value(const Type & a_value) throw();
360 void copy_carray(const Type * a_carray) throw();
363 void copy_array(const
array<Type> & a_source) throw();
367 template <typename Type>
368 void array<Type>::assign_value(const Type & a_value) throw()
372 for (
size_t n = 0; n <
m_size; ++n)
374 *element_ptr = a_value;
380 template <
typename Type>
385 const Type * carray_ptr = a_carray;
387 for (
size_t n = 0; n <
m_size; ++n)
389 *target_ptr = *carray_ptr;
396 template <
typename Type>
397 void array<Type>::copy_array(
const array<Type> & a_source)
throw()
404 const Type * source_ptr = a_source.
m_array;
406 for (
size_t n = 0; n < copy_length; ++n)
408 *target_ptr = *source_ptr;
415 template <
typename Type>
421 enforce_lower_limit(
m_size,
size_t(1));
428 template <
typename Type>
434 enforce_lower_limit(
m_size,
size_t(1));
444 template <
typename Type>
457 template <
typename Type>
466 enforce_lower_limit(
m_size,
size_t(1));
476 template <
typename Type>
486 template <
typename Type>
494 template <
typename Type>
502 template <
typename Type>
510 template <
typename Type>
517 template <
typename Type>
520 LIBCOYOTL_ARRAY_CHECK_INDEX(
n)
524 template <
typename Type>
527 LIBCOYOTL_ARRAY_CHECK_INDEX(
n)
532 template <
typename Type>
567 template <
typename Type>
573 template <
typename Type>
579 template <
typename Type>
585 template <
typename Type>
591 template <
typename Type>
597 template <
typename Type>
603 template <
typename Type>
609 template <
typename Type>
616 template <
typename Type>
622 template <
typename Type>
628 template <
typename Type>
634 template <
typename Type>
640 template <
typename Type>
646 template <
typename Type>
653 template <
typename Type>
663 for (
size_t n = 0;
n < m_size; ++
n)
675 template <
typename Type>
682 template <
typename Type>
689 template <
typename Type>
A STL-compatible array class.
Definition array.h:73
Type * iterator
Iterator type.
Definition array.h:97
bool operator==(const array< Type > &a_comparand) const
Equals operator.
Definition array.h:617
Type & operator[](size_t n)
Element access.
Definition array.h:518
bool operator>(const array< Type > &a_comparand) const
Greater-than operator.
Definition array.h:635
Type * m_array
Underlying allocated array.
Definition array.h:350
size_t max_size() const
Maximum container size.
Definition array.h:683
Type & reference
Type of a reference to an element.
Definition array.h:85
array & operator=(const array< Type > &a_source)
Assignment operator.
Definition array.h:487
ptrdiff_t difference_type
Difference type between two element pointers.
Definition array.h:91
bool operator<=(const array< Type > &a_comparand) const
Less-than-or-equal-to operator.
Definition array.h:641
bool empty() const
Empty container check.
Definition array.h:690
array(size_t a_length)
Default constructor.
Definition array.h:416
Type * reverse_iterator
Reverse iterator type.
Definition array.h:103
const Type * const_pointer
Type of a constant pointer to an element.
Definition array.h:82
const Type * const_iterator
Constant iterator type.
Definition array.h:100
bool operator>=(const array< Type > &a_comparand) const
Greater-than-or-equal-to operator.
Definition array.h:647
const Type * const_reverse_iterator
Constant reverse iterator type.
Definition array.h:106
Type value_type
Type of an array element.
Definition array.h:76
size_t size() const
Number of elements.
Definition array.h:676
virtual ~array()
Virtual destructor.
Definition array.h:477
const Type * c_array() const
Conversion to C-style array.
Definition array.h:511
size_t m_size
Length of the array.
Definition array.h:353
iterator end()
Obtain end-of-sequence iterator.
Definition array.h:580
const Type & const_reference
Type of a constant reference to an element.
Definition array.h:88
void append(const array< Type > &a_array)
Appending arrays.
Definition array.h:533
iterator begin()
Obtain beginning-of-sequence iterator.
Definition array.h:568
bool operator<(const array< Type > &a_comparand) const
Less-than operator.
Definition array.h:629
Type * pointer
type of a pointer to an element
Definition array.h:79
iterator rend()
Obtain end-of-sequence reverse iterator.
Definition array.h:604
bool operator!=(const array< Type > &a_comparand) const
Inequality operator.
Definition array.h:623
void swap(array< Type > &a_source)
Exchanges the corresponding elements of two arrays.
Definition array.h:654
size_t size_type
Size type for indexing array elements.
Definition array.h:94
iterator rbegin()
Obtain beginning-of-sequence reverse iterator.
Definition array.h:592