ADMB Documentation  11.1.2490
 All Classes Files Functions Variables Typedefs Friends Defines
clist.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id: clist.cpp 1919 2014-04-22 22:02:01Z johnoel $
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00007 #include "clist.h"
00008 
00009 clist * clist::prev(void)
00010 {
00011   clist * tmp = this->next;
00012   while (tmp->next != this) tmp = tmp->next;
00013   return (tmp);
00014 }
00015 
00016 int  clist::length(const int & max)
00017 {
00018   int num = 1;
00019   clist * tmp = this;
00020   while (tmp->next != this)
00021   {
00022     tmp = tmp->next;
00023     if (++num > max)
00024     {
00025       return (-1);
00026     }
00027   }
00028   return (num);
00029 }
00030 
00031 clist::clist(const clist & t)
00032 {
00033   clist& tmp=*(clist *)(&t);
00034   next = t.next;
00035   tmp.next = this;
00036 }
00037 
00038 clist::~clist()
00039 {
00040   if (next == this)
00041   {
00042     next = 0;
00043   }
00044   else
00045   {
00046     prev()->next = next;
00047   }
00048 }