Back to index

texmacs  1.0.7.15
Classes | Defines | Functions
array.hpp File Reference
#include "basic.hpp"
#include "array.cpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  array_rep< T >
class  array< T >

Defines

#define TMPL   template<class T>

Functions

template<class T >
int N (array< T > a)
template<class T >
TA (array< T > a)
template<class T >
array< Tcopy (array< T > x)
 CONCRETE_TEMPLATE_CODE (array, class, T)
TMPL tm_ostreamoperator<< (tm_ostream &out, array< T > a)
TMPL array< T > & operator<< (array< T > &a, T x)
TMPL array< T > & operator<< (array< T > &a, array< T > b)
TMPL array< Tappend (T a, array< T > b)
TMPL array< Tappend (array< T > a, array< T > b)
TMPL array< Trange (array< T > a, int i, int j)
TMPL array< Treverse (array< T > a)
TMPL bool operator== (array< T > a, array< T > b)
TMPL bool operator!= (array< T > a, array< T > b)
TMPL int hash (array< T > a)

Define Documentation

#define TMPL   template<class T>

Definition at line 48 of file array.hpp.


Function Documentation

template<class T >
TMPL T * A ( array< T a) [inline]

Definition at line 50 of file array.hpp.

{ return a->a; }
TMPL array<T> append ( T  a,
array< T b 
)

Definition at line 119 of file array.cpp.

                         {
  register int i, l= N(b);
  array<T> c (l+1);
  c[0]= a;
  for (i=0; i<l; i++) c[i+1]= b[i];
  return c;
}

Here is the call graph for this function:

TMPL array<T> append ( array< T a,
array< T b 
)

Definition at line 128 of file array.cpp.

                                {
  register int i, k= N(a), l= N(b);
  array<T> c (k+l);
  for (i=0; i<k; i++) c[i]= a[i];
  for (i=0; i<l; i++) c[i+k]= b[i];
  return c;
}

Here is the call graph for this function:

CONCRETE_TEMPLATE_CODE ( array  ,
class  ,
T   
)
template<class T >
TMPL array< T > copy ( array< T x) [inline]

Definition at line 51 of file array.hpp.

                                       {
  return array<T> (a->a, a->n); }
TMPL int hash ( array< T a)

Definition at line 154 of file array.cpp.

                  {
  int i, n=N(a), h= 0;
  for (i=0; i<n; i++)
    h= hash(a[i]) ^ ((h<<7) + (h>>25));
  return h;
}

Here is the call graph for this function:

template<class T >
TMPL int N ( array< T a) [inline]

Definition at line 49 of file array.hpp.

{ return a->n; }
TMPL bool operator!= ( array< T a,
array< T b 
)

Definition at line 82 of file array.cpp.

                                     {
  register int i;
  if (N(a)!=N(b)) return true;
  for (i=0; i<N(a); i++)
    if (a[i]!=b[i]) return true;
  return false;
}

Here is the call graph for this function:

TMPL tm_ostream& operator<< ( tm_ostream out,
array< T a 
)

Definition at line 91 of file array.cpp.

                                          {
  int i;
  
  if (N(a)==0) return out << "[ ]";
  out << "[ ";
  for (i=0; i<N(a)-1; i++)
    out << a[i] << ", ";
  if (N(a)!=0) out << a[i];
  out << " ]";
  return out;
}

Here is the call graph for this function:

TMPL array<T>& operator<< ( array< T > &  a,
T  x 
)

Definition at line 104 of file array.cpp.

                               {
  a->resize (N(a)+ 1);
  a[N(a)-1]=x;
  return a;
}

Here is the call graph for this function:

TMPL array<T>& operator<< ( array< T > &  a,
array< T b 
)

Definition at line 111 of file array.cpp.

                                      {
  register int i, k= N(a);
  a->resize (N(a)+ N(b));
  for (i=0; i<N(b); i++) a[i+k]= b[i];
  return a;
}

Here is the call graph for this function:

TMPL bool operator== ( array< T a,
array< T b 
)

Definition at line 73 of file array.cpp.

                                     {
  register int i;
  if (N(a)!=N(b)) return false;
  for (i=0; i<N(a); i++)
    if (a[i]!=b[i]) return false;
  return true;
}

Here is the call graph for this function:

TMPL array<T> range ( array< T a,
int  i,
int  j 
)

Definition at line 137 of file array.cpp.

                                 {
  register int k;
  ASSERT (i>=0 && j<=N(a), "out of range");
  array<T> r (j-i);
  for (k=i; k<j; k++) r[k-i]= a[k];
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TMPL array<T> reverse ( array< T a)

Definition at line 146 of file array.cpp.

                     {
  register int i, n= N(a);
  array<T> r (n);
  for (i=0; i<n; i++) r[i]= a[n-1-i];
  return r;
}

Here is the call graph for this function: