Revision 1544

trunk/src/sparse/tescl.h (revision 1544)
1
/*
2
 * $Id$
3
 *
4
 * Author: David Fournier
5
 * Copyright (c) 2008-2012 Regents of the University of California 
6
 * 
7
 * ADModelbuilder and associated libraries and documentations are
8
 * provided under the general terms of the "BSD" license.
9
 * 
10
 * License:
11
 * 
12
 * Redistribution and use in source and binary forms, with or without
13
 * modification, are permitted provided that the following conditions are
14
 * met:
15
 * 
16
 * 1. Redistributions of source code must retain the above copyright
17
 * notice, this list of conditions and the following disclaimer.
18
 * 
19
 * 2.  Redistributions in binary form must reproduce the above copyright
20
 * notice, this list of conditions and the following disclaimer in the
21
 * documentation and/or other materials provided with the distribution.
22
 * 
23
 * 3.  Neither the name of the  University of California, Otter Research,
24
 * nor the ADMB Foundation nor the names of its contributors may be used
25
 * to endorse or promote products derived from this software without
26
 * specific prior written permission.
27
 * 
28
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
 *
40
 */
41

  
42
#ifndef CLIST_H
43
#define CLIST_H
44
class clist
45
{
46
public :
47
  int length(const int & max = 1000);
48
protected :
49
  clist * next;
50
  virtual here()=0;
51
  clist() { next = here(); }
52
  clist(const clist & pt);
53
  clist * prev(void);
54
public:
55
  ~clist();
56
};
57

  
58

  
59
clist * clist::prev(void)
60
{
61
  clist * tmp = this->next;
62
  while (tmp->next != this) tmp = tmp->next;
63
  return (tmp);
64
}
65
 
66
int  clist::length(const int & max)
67
{
68
  int num = 1;
69
  clist * tmp = this;
70
  while (tmp->next != this)
71
  {
72
    tmp = tmp->next;
73
    if (++num > max)
74
    {
75
      return (-1);
76
    }
77
  }
78
  return (num);
79
}
80

  
81
clist::clist(const clist & t)
82
{
83
  clist& tmp=t.here(); 
84
  next = t.next;
85
  tmp.next = this;
86
}
87
 
88
 
89
clist::~clist()
90
{
91
  if (next == here())
92
  {
93
    next = 0;
94
  }
95
  else
96
  {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff