Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

slist_base Class Reference

#include <nilist.h>

Inheritance diagram for slist_base:

Inheritance graph
[legend]
Collaboration diagram for slist_base:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 slist_base ()
 slist_base (slink *a)
void insert (slink *a)
void append (slink *a)
void remove (slink *a, slink *prev)
slinkget ()
slinkfind (int key)
void clear ()
int count ()
slinklast ()
int ac ()
int rc ()

Private Attributes

slinklast_
int count_
int append_count_
int remove_count_

Friends

class slist_base_iter

Constructor & Destructor Documentation

slist_base::slist_base  )  [inline]
 

Definition at line 52 of file nilist.h.

References append_count_, count_, last_, and remove_count_.

slist_base::slist_base slink a  )  [inline]
 

Definition at line 53 of file nilist.h.

References last_, and slink::next_.

00053 {last_ = a->next_ = a;}


Member Function Documentation

int slist_base::ac  )  [inline]
 

Definition at line 65 of file nilist.h.

References append_count_.

00065 {return append_count_;} /* XXX */

void slist_base::append slink a  ) 
 

Definition at line 80 of file nilist.cc.

References append_count_, count_, last_, and slink::next_.

Referenced by Slist< T >::append(), and Islist< Segment >::append().

00081 {
00082     append_count_++; /* XXX */
00083     count_++;
00084     if (last_) {
00085         a->next_ = last_->next_;
00086         last_ = last_->next_ = a;
00087     }
00088     else
00089         last_ = a->next_ = a;
00090 }

void slist_base::clear  )  [inline]
 

Definition at line 62 of file nilist.h.

References last_.

00062 {last_ = 0;}

int slist_base::count  )  [inline]
 

Reimplemented in Islist< T >, Islist< TcpSessionAgent >, Islist< IntTcpAgent >, and Islist< Segment >.

Definition at line 63 of file nilist.h.

References count_.

Referenced by slist_base_iter::count(), and Islist< Segment >::count().

00063 {return count_;}        

slink * slist_base::find int  key  ) 
 

Reimplemented in Islist< T >, Islist< TcpSessionAgent >, Islist< IntTcpAgent >, and Islist< Segment >.

Definition at line 104 of file nilist.cc.

References slink::key_, last_, and slink::next_.

Referenced by Islist< Segment >::find().

00105 {
00106     slink *cur = last_;
00107     
00108     if (last_ == 0) return NULL;
00109     do {
00110         cur = cur->next_;
00111         if (cur->key_ == key)
00112             return cur;
00113     } while (cur != last_);
00114     return NULL;
00115 }

slink * slist_base::get  ) 
 

Reimplemented in Islist< T >, Slist< T >, Islist< TcpSessionAgent >, Islist< IntTcpAgent >, and Islist< Segment >.

Definition at line 92 of file nilist.cc.

References count_, last_, and slink::next_.

Referenced by Islist< Segment >::get(), and Slist< T >::get().

00093 {
00094     count_--;
00095     if (last_ == 0) return NULL;
00096     slink * f = last_->next_;
00097     if (f == last_)
00098         last_ = 0;
00099     else 
00100         last_->next_ = f->next_;
00101     return f;
00102 }

void slist_base::insert slink a  ) 
 

Definition at line 48 of file nilist.cc.

References count_, last_, and slink::next_.

Referenced by Slist< T >::insert(), and Islist< Segment >::insert().

00049 {
00050     count_++;
00051     if (last_)
00052         a->next_ = last_->next_;
00053     else
00054         last_ = a;
00055     last_->next_ = a;
00056 }

slink* slist_base::last  )  [inline]
 

Definition at line 64 of file nilist.h.

References last_.

00064 {return last_;}    /* XXX */

int slist_base::rc  )  [inline]
 

Definition at line 66 of file nilist.h.

References remove_count_.

00066 {return remove_count_;} /* XXX */

void slist_base::remove slink a,
slink prev
 

Definition at line 59 of file nilist.cc.

References count_, last_, slink::next_, and remove_count_.

Referenced by Islist< Segment >::remove().

00060 {
00061     remove_count_++; /* XXX */
00062     count_--;
00063     if (prev && prev->next_ != a)
00064             printf("In remove(): Error: prev->next!=a  prev=%p  a=%p\n", prev, a);
00065     if (last_ == NULL) 
00066         return;
00067     if (prev == NULL)
00068         if (last_->next_ == a)
00069             prev = last_;
00070         else 
00071             return;
00072 
00073     prev->next_ = a->next_;
00074     if (last_ == a)             // a was last in list
00075         last_ = prev;
00076     if (last_->next_ == a)      // a was only one in list
00077         last_ = NULL;
00078 }


Friends And Related Function Documentation

friend class slist_base_iter [friend]
 

Definition at line 67 of file nilist.h.


Member Data Documentation

int slist_base::append_count_ [private]
 

Definition at line 49 of file nilist.h.

Referenced by ac(), append(), and slist_base().

int slist_base::count_ [private]
 

Definition at line 48 of file nilist.h.

Referenced by append(), count(), get(), insert(), remove(), and slist_base().

slink* slist_base::last_ [private]
 

Definition at line 47 of file nilist.h.

Referenced by append(), clear(), find(), get(), slist_base_iter::get_last(), insert(), last(), slist_base_iter::operator()(), remove(), slist_base(), and slist_base_iter::slist_base_iter().

int slist_base::remove_count_ [private]
 

Definition at line 50 of file nilist.h.

Referenced by rc(), remove(), and slist_base().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:23:29 2004 for NS2.26SourcesOriginal by doxygen 1.3.3