Back to index

tetex-bin  3.0
Public Member Functions | Private Member Functions | Private Attributes
GList Class Reference

#include <GList.h>

List of all members.

Public Member Functions

 GList ()
 GList (int sizeA)
 ~GList ()
int getLength ()
voidget (int i)
void append (void *p)
void append (GList *list)
void insert (int i, void *p)
voiddel (int i)
void setAllocIncr (int incA)

Private Member Functions

void expand ()
void shrink ()

Private Attributes

void ** data
int size
int length
int inc

Detailed Description

Definition at line 24 of file GList.h.


Constructor & Destructor Documentation

Definition at line 23 of file GList.cc.

             {
  size = 8;
  data = (void **)gmalloc(size * sizeof(void*));
  length = 0;
  inc = 0;
}

Here is the call graph for this function:

GList::GList ( int  sizeA)

Definition at line 30 of file GList.cc.

                      {
  size = sizeA;
  data = (void **)gmalloc(size * sizeof(void*));
  length = 0;
  inc = 0;
}

Here is the call graph for this function:

Definition at line 37 of file GList.cc.

              {
  gfree(data);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 41 of file GList.cc.

                          {
  if (length >= size) {
    expand();
  }
  data[length++] = p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GList::append ( GList list)

Definition at line 48 of file GList.cc.

                              {
  int i;

  while (length + list->length > size) {
    expand();
  }
  for (i = 0; i < list->length; ++i) {
    data[length++] = list->data[i];
  }
}

Here is the call graph for this function:

void * GList::del ( int  i)

Definition at line 70 of file GList.cc.

                      {
  void *p;

  p = data[i];
  if (i < length - 1) {
    memmove(data+i, data+i+1, (length - i - 1) * sizeof(void *));
  }
  --length;
  if (size - length >= ((inc > 0) ? inc : size/2)) {
    shrink();
  }
  return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GList::expand ( ) [private]

Definition at line 84 of file GList.cc.

                   {
  size += (inc > 0) ? inc : size;
  data = (void **)grealloc(data, size * sizeof(void*));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* GList::get ( int  i) [inline]

Definition at line 45 of file GList.h.

{ return data[i]; }

Here is the caller graph for this function:

int GList::getLength ( ) [inline]

Definition at line 39 of file GList.h.

{ return length; }

Here is the caller graph for this function:

void GList::insert ( int  i,
void p 
)

Definition at line 59 of file GList.cc.

                                 {
  if (length >= size) {
    expand();
  }
  if (i < length) {
    memmove(data+i+1, data+i, (length - i) * sizeof(void *));
  }
  data[i] = p;
  ++length;
}

Here is the call graph for this function:

void GList::setAllocIncr ( int  incA) [inline]

Definition at line 66 of file GList.h.

{ inc = incA; }
void GList::shrink ( ) [private]

Definition at line 89 of file GList.cc.

                   {
  size -= (inc > 0) ? inc : size/2;
  data = (void **)grealloc(data, size * sizeof(void*));
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

void** GList::data [private]

Definition at line 73 of file GList.h.

int GList::inc [private]

Definition at line 76 of file GList.h.

int GList::length [private]

Definition at line 75 of file GList.h.

int GList::size [private]

Definition at line 74 of file GList.h.


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