OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | List of all members
SimpleIntArray Class Reference

#include <newmat.h>

Inheritance diagram for SimpleIntArray:

Public Member Functions

 SimpleIntArray (int xn)
 
 ~SimpleIntArray ()
 
int & operator[] (int i)
 
int operator[] (int i) const
 
void operator= (int ai)
 
void operator= (const SimpleIntArray &b)
 
 SimpleIntArray (const SimpleIntArray &b)
 
int Size () const
 
int * Data ()
 
const int * Data () const
 
void ReSize (int i, bool keep=false)
 
void CleanUp ()
 

Protected Attributes

int * a
 
int n
 

Detailed Description

Definition at line 1585 of file newmat.h.

Constructor & Destructor Documentation

◆ SimpleIntArray() [1/2]

SimpleIntArray::SimpleIntArray ( int  xn)

Definition at line 933 of file newmat4.cpp.

References a, n, and REPORT.

933  : n(xn)
934 {
935  if (n < 0) Throw(Logic_error("invalid array length"));
936  else if (n == 0) { REPORT a = 0; }
937  else { REPORT a = new int [n]; if (!a) Throw(Bad_alloc()); }
938 }
#define REPORT
Definition: newmat4.cpp:19

◆ ~SimpleIntArray()

SimpleIntArray::~SimpleIntArray ( )

Definition at line 942 of file newmat4.cpp.

References a, and REPORT.

942 { REPORT if (a) delete [] a; }
#define REPORT
Definition: newmat4.cpp:19

◆ SimpleIntArray() [2/2]

SimpleIntArray::SimpleIntArray ( const SimpleIntArray b)

Definition at line 984 of file newmat4.cpp.

References a, n, and REPORT.

984  : n(b.n)
985 {
986  if (n == 0) { REPORT a = 0; }
987  else
988  {
989  REPORT
990  a = new int [n]; if (!a) Throw(Bad_alloc());
991  for (int i = 0; i < n; i++) a[i] = b.a[i];
992  }
993 }
#define REPORT
Definition: newmat4.cpp:19

Member Function Documentation

◆ CleanUp()

void SimpleIntArray::CleanUp ( )
inline

Definition at line 1608 of file newmat.h.

1608 { ReSize(0); }
void ReSize(int i, bool keep=false)
Definition: newmat4.cpp:998

◆ Data() [1/2]

int* SimpleIntArray::Data ( )
inline

Definition at line 1603 of file newmat.h.

1603 { return a; } // pointer to the data

◆ Data() [2/2]

const int* SimpleIntArray::Data ( ) const
inline

Definition at line 1604 of file newmat.h.

1604 { return a; }

◆ operator=() [1/2]

void SimpleIntArray::operator= ( int  ai)

Definition at line 968 of file newmat4.cpp.

References a, n, and REPORT.

969  { REPORT for (int i = 0; i < n; i++) a[i] = ai; }
#define REPORT
Definition: newmat4.cpp:19

◆ operator=() [2/2]

void SimpleIntArray::operator= ( const SimpleIntArray b)

Definition at line 974 of file newmat4.cpp.

References a, n, and REPORT.

975 {
976  REPORT
977  if (b.n != n) Throw(Logic_error("array lengths differ in copy"));
978  for (int i = 0; i < n; i++) a[i] = b.a[i];
979 }
#define REPORT
Definition: newmat4.cpp:19

◆ operator[]() [1/2]

int & SimpleIntArray::operator[] ( int  i)

Definition at line 949 of file newmat4.cpp.

References a, n, and REPORT.

950 {
951  REPORT
952  if (i < 0 || i >= n) Throw(Logic_error("array index out of range"));
953  return a[i];
954 }
#define REPORT
Definition: newmat4.cpp:19

◆ operator[]() [2/2]

int SimpleIntArray::operator[] ( int  i) const

Definition at line 959 of file newmat4.cpp.

References a, n, and REPORT.

960 {
961  REPORT
962  if (i < 0 || i >= n) Throw(Logic_error("array index out of range"));
963  return a[i];
964 }
#define REPORT
Definition: newmat4.cpp:19

◆ ReSize()

void SimpleIntArray::ReSize ( int  i,
bool  keep = false 
)

Definition at line 998 of file newmat4.cpp.

References a, n, and REPORT.

999 {
1000  if (n1 == n) { REPORT return; }
1001  else if (n1 == 0) { REPORT n = 0; delete [] a; a = 0; }
1002  else if (n == 0)
1003  { REPORT a = new int [n1]; if (!a) Throw(Bad_alloc()); n = n1; }
1004  else
1005  {
1006  int* a1 = a;
1007  if (keep)
1008  {
1009  REPORT
1010  a = new int [n1]; if (!a) Throw(Bad_alloc());
1011  if (n > n1) n = n1;
1012  for (int i = 0; i < n; i++) a[i] = a1[i];
1013  n = n1; delete [] a1;
1014  }
1015  else
1016  {
1017  REPORT n = n1; delete [] a1;
1018  a = new int [n]; if (!a) Throw(Bad_alloc());
1019  }
1020  }
1021 }
#define REPORT
Definition: newmat4.cpp:19

◆ Size()

int SimpleIntArray::Size ( ) const
inline

Definition at line 1601 of file newmat.h.

References n.

1601 { return n; }

Member Data Documentation

◆ a

int* SimpleIntArray::a
protected

Definition at line 1588 of file newmat.h.

Referenced by operator=(), operator[](), ReSize(), SimpleIntArray(), and ~SimpleIntArray().

◆ n

int SimpleIntArray::n
protected

Definition at line 1589 of file newmat.h.

Referenced by operator=(), operator[](), ReSize(), and SimpleIntArray().


The documentation for this class was generated from the following files: