Statistics
| Revision:

root / trunk / src / tools99 / clist.cpp @ 1138

History | View | Annotate | Download (656 Bytes)

1
/*
2
 * $Id: clist.cpp 1138 2013-08-05 20:25:57Z johnoel $
3
 *
4
 * Author: David Fournier
5
 * Copyright (c) 2008-2012 Regents of the University of California
6
 */
7
#include "clist.h"
8

    
9
clist * clist::prev(void)
10
{
11
  clist * tmp = this->next;
12
  while (tmp->next != this) tmp = tmp->next;
13
  return (tmp);
14
}
15

    
16
int  clist::length(const int & max)
17
{
18
  int num = 1;
19
  clist * tmp = this;
20
  while (tmp->next != this)
21
  {
22
    tmp = tmp->next;
23
    if (++num > max)
24
    {
25
      return (-1);
26
    }
27
  }
28
  return (num);
29
}
30

    
31
clist::clist(const clist & t)
32
{
33
  clist& tmp=*(clist *)(&t);
34
  next = t.next;
35
  tmp.next = this;
36
}
37

    
38
clist::~clist()
39
{
40
  if (next == this)
41
  {
42
    next = 0;
43
  }
44
  else
45
  {
46
    prev()->next = next;
47
  }
48
}