- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Containers/IntegerArray.h

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #if !defined(AFX_INTEGERARRAY_H__F73691C3_664E_4AB5_B252_754425F3BE92__INCLUDED_)
    00015 #define AFX_INTEGERARRAY_H__F73691C3_664E_4AB5_B252_754425F3BE92__INCLUDED_
    00016
    00017 #if _MSC_VER > 1000
    00018 #pragma once
    00019 #endif // _MSC_VER > 1000
    00020
    00021 #include "DynamicArray.h"
    00022
    00023 namespace Mers {
    00024         namespace Utils {
    00025                 namespace Containers {
    00026
    00032                         class IntegerArray : public DynamicArray
    00033                         {
    00034                         public:
    00035                                 //-----------------------------------------
    00036                                 // Constructors
    00037                                 //-----------------------------------------
    00038
    00042                                 IntegerArray();
    00043
    00044                                 //-----------------------------------------
    00045                                 // Copy constructors
    00046                                 //-----------------------------------------
    00047
    00054                                 IntegerArray(IntegerArray const &other);
    00061                                 IntegerArray(IntegerArray const * other);
    00062
    00063                                 //-----------------------------------------
    00064                                 // Destructors
    00065                                 //-----------------------------------------
    00066
    00070                                 virtual ~IntegerArray();
    00071
    00072                                 //-----------------------------------------
    00073                                 // Iterators
    00074                                 //-----------------------------------------
    00075
    00076                                 typedef int * pointer;
    00077                                 typedef const int * const_pointer;
    00078                                 typedef IntegerArray ContainerType;
    00079                                 typedef IteratorTemplate<const_pointer, ContainerType> const_iterator;
    00080                                 typedef IteratorTemplate<pointer, ContainerType> iterator;
    00081                                 typedef const_iterator ConstantIterator;
    00082                                 typedef iterator Iterator;
    00083
    00084                                 //-----------------------------------------
    00085                                 // Functions
    00086                                 //-----------------------------------------
    00087
    00094                                 iterator begin()
    00095                                 {
    00096                                         return iterator(this, 0);
    00097                                 }
    00104                                 const_iterator begin() const
    00105                                 {
    00106                                         return const_iterator((ContainerType *)this, 0);
    00107                                 }
    00108
    00115                                 iterator end()
    00116                                 {
    00117                                         return iterator(this, getLength());
    00118                                 }
    00125                                 const_iterator end() const
    00126                                 {
    00127                                         return const_iterator((ContainerType *)this, getLength());
    00128                                 }
    00129
    00141                                 int pushBack(int data);
    00149                                 int popBack();
    00150
    00159                                 void insert(unsigned int elementIndex, int data)
    00160                                 {
    00161                                         DynamicArray::insert(elementIndex, (void *) data);
    00162                                 }
    00163
    00169                                 void setArrayTo(int value);
    00173                                 void setArrayToZero();
    00174
    00175                                 //-----------------------------------------
    00176                                 // Operators
    00177                                 //-----------------------------------------
    00178
    00187                                 int & operator[](int elementIndex);
    00196                                 int & operator[](unsigned int elementIndex);
    00205                                 int & operator[](int elementIndex) const;
    00214                                 int & operator[](unsigned int elementIndex) const;
    00215
    00225                                 IntegerArray const & operator =(IntegerArray const &other);
    00234                                 IntegerArray const & operator +=(IntegerArray const &other);
    00244                                 IntegerArray const & operator +=(int data);
    00245
    00246 #ifndef EMBEDDED
    00247
    00256                                 void print(std::ostream &out) const;
    00257
    00258 #endif
    00259
    00260                         protected:
    00261                                 //-----------------------------------------
    00262                                 // Functions
    00263                                 //-----------------------------------------
    00264
    00265 #ifndef EMBEDDED
    00266
    00275                                 void printElement(std::ostream &out, void const * element) const;
    00276 #endif
    00277
    00285                                 void deleteElement(void * element) const;
    00294                                 void * newElement(void const * element) const;
    00305                                 bool isEqual(void const * element1, void const * element2) const;
    00306                         };
    00307                 }
    00308         }
    00309 }
    00310
    00311 #endif // !defined(AFX_INTEGERARRAY_H__F73691C3_664E_4AB5_B252_754425F3BE92__INCLUDED_)