Back to index

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

Go to the source code of this file.

Classes

class  list< T >
class  list_rep< T >

Defines

#define TMPL   template<class T>

Functions

template<class T >
bool is_nil (list< T > l)
template<class T >
bool is_atom (list< T > l)
template<class T >
bool strong_equal (list< T > l1, list< T > l2)
 CONCRETE_NULL_TEMPLATE_CODE (list, class, T)
TMPL int N (list< T > l)
TMPL list< Tcopy (list< T > l)
TMPL list< Toperator* (list< T > l1, T x)
TMPL list< Toperator* (list< T > l1, list< T > l2)
TMPL list< Thead (list< T > l, int n=1)
TMPL list< Ttail (list< T > l, int n=1)
TMPL T last_item (list< T > l)
TMPL Taccess_last (list< T > &l)
TMPL list< T > & suppress_last (list< T > &l)
TMPL list< Treverse (list< T > l)
TMPL list< Tremove (list< T > l, T what)
TMPL bool contains (list< T > l, T what)
TMPL tm_ostreamoperator<< (tm_ostream &out, list< T > l)
TMPL list< T > & operator<< (list< T > &l, T item)
TMPL list< T > & operator<< (list< T > &l1, list< T > l2)
TMPL list< T > & operator>> (T item, list< T > &l)
TMPL list< T > & operator<< (T &item, list< T > &l)
TMPL bool operator== (list< T > l1, list< T > l2)
TMPL bool operator!= (list< T > l1, list< T > l2)
TMPL bool operator< (list< T > l1, list< T > l2)
TMPL bool operator<= (list< T > l1, list< T > l2)

Variables

int list_count

Define Documentation

#define TMPL   template<class T>

Definition at line 51 of file list.hpp.


Function Documentation

TMPL T& access_last ( list< T > &  l)

Definition at line 88 of file list.cpp.

                         {
  ASSERT (!is_nil (l), "empty path");
  if (is_nil (l->next)) return l->item;
  return access_last (l->next);
}

Here is the call graph for this function:

Here is the caller graph for this function:

CONCRETE_NULL_TEMPLATE_CODE ( list  ,
class  ,
T   
)
TMPL bool contains ( list< T l,
T  what 
)

Definition at line 197 of file list.cpp.

                             {
  return (!is_nil(l) && (l->item == what || contains(l->next, what)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

TMPL list<T> copy ( list< T l)

Definition at line 146 of file list.cpp.

                 {
  if (is_nil (l)) return list<T> ();
  else return list<T> (l->item, copy (l->next));
}

Here is the call graph for this function:

TMPL list<T> head ( list< T l,
int  n = 1 
)

Definition at line 164 of file list.cpp.

                        {
  if (n==0) return list<T> ();
  ASSERT (!is_nil (l), "list too short");
  return list<T> (l->item, head (l->next, n-1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
TMPL bool is_atom ( list< T l) [inline]

Definition at line 59 of file list.hpp.

{ return (!is_nil (l)) && is_nil (l->next); }

Here is the call graph for this function:

template<class T >
bool is_nil ( list< T l)
TMPL T last_item ( list< T l)

Definition at line 81 of file list.cpp.

                      {
  ASSERT (!is_nil (l), "empty path");
  if (is_nil (l->next)) return l->item;
  return last_item (l->next);
}

Here is the call graph for this function:

TMPL int N ( list< T l)

Definition at line 140 of file list.cpp.

              {
  if (is_nil (l)) return 0;
  else return N (l->next) + 1;
}

Here is the call graph for this function:

TMPL bool operator!= ( list< T l1,
list< T l2 
)

Definition at line 118 of file list.cpp.

                                     {
  if (is_nil (l1) || is_nil (l2)) return (is_nil (l1) != is_nil (l2));
  return (l1->item!=l2->item) || (l1->next!=l2->next);
}

Here is the call graph for this function:

TMPL list<T> operator* ( list< T l1,
T  x 
)

Definition at line 152 of file list.cpp.

                             {
  if (is_nil (l1)) return x;
  else return list<T> (l1->item, l1->next * x);
}

Here is the call graph for this function:

TMPL list<T> operator* ( list< T l1,
list< T l2 
)

Definition at line 158 of file list.cpp.

                                    {
  if (is_nil (l1)) return copy (l2);
  else return list<T> (l1->item, l1->next * l2);
}

Here is the call graph for this function:

TMPL bool operator< ( list< T l1,
list< T l2 
)

Definition at line 124 of file list.cpp.

                                    {
  if (is_nil (l1) || is_nil (l2)) return !is_nil (l2);
  return (l1->item==l2->item) && (l1->next<l2->next);
}

Here is the call graph for this function:

TMPL tm_ostream& operator<< ( tm_ostream out,
list< T l 
)

Definition at line 21 of file list.cpp.

                                         {
  out << "[";
  if (!is_nil (l)) {
    out << " " << l->item;
    l=l->next;
  }
  while (!is_nil (l)) {
    out << ", " << l->item;
    l=l->next;
  }
  return out << " ]";
}

Here is the call graph for this function:

TMPL list<T>& operator<< ( list< T > &  l,
T  item 
)

Definition at line 55 of file list.cpp.

                                 {
  if (is_nil (l)) l= list<T> (item, list<T> ());
  else l->next << item;
  return l;
}

Here is the call graph for this function:

TMPL list<T>& operator<< ( list< T > &  l1,
list< T l2 
)

Definition at line 62 of file list.cpp.

                                      {
  if (is_nil (l1)) l1= l2;
  else l1->next << l2;
  return l1;
}

Here is the call graph for this function:

TMPL list<T>& operator<< ( T item,
list< T > &  l 
)

Definition at line 74 of file list.cpp.

                                  {
  item= l->item;
  l   = l->next;
  return l;
}
TMPL bool operator<= ( list< T l1,
list< T l2 
)

Definition at line 130 of file list.cpp.

                                     {
  if (is_nil (l1) || is_nil (l2)) return is_nil (l1);
  return (l1->item==l2->item) && (l1->next<=l2->next);
}

Here is the call graph for this function:

TMPL bool operator== ( list< T l1,
list< T l2 
)

Definition at line 112 of file list.cpp.

                                     {
  if (is_nil (l1) || is_nil (l2)) return (is_nil (l1) == is_nil (l2));
  return (l1->item==l2->item) && (l1->next==l2->next);
}

Here is the call graph for this function:

TMPL list<T>& operator>> ( T  item,
list< T > &  l 
)

Definition at line 69 of file list.cpp.

                                 {
  return (l= list<T> (item, l));
}
TMPL list<T> remove ( list< T l,
T  what 
)

Definition at line 190 of file list.cpp.

                           {
  if (is_nil (l)) return l;
  else if (l->item == what) return remove (l->next, what);
  else return list<T> (l->item, remove (l->next, what));
}

Here is the call graph for this function:

TMPL list<T> reverse ( list< T l)

Definition at line 180 of file list.cpp.

                    {
  list<T> r;
  while (!is_nil(l)) {
    r= list<T> (l->item, r);
    l=l->next;
  }
  return r;
}

Here is the call graph for this function:

template<class T >
bool strong_equal ( list< T l1,
list< T l2 
)

Definition at line 107 of file list.cpp.

                                      {
  return l1.rep == l2.rep;
}

Here is the caller graph for this function:

TMPL list<T>& suppress_last ( list< T > &  l)

Definition at line 95 of file list.cpp.

                           {
  ASSERT (!is_nil (l), "empty path");
  if (is_nil (l->next)) l= list<T> ();
  else suppress_last (l->next);
  return l;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TMPL list<T> tail ( list< T l,
int  n = 1 
)

Definition at line 171 of file list.cpp.

                        {
  for (; n>0; n--) {
    ASSERT (!is_nil (l), "list too short");
    l=l->next;
  }
  return l;
}

Here is the call graph for this function:


Variable Documentation