Polaris: BaseRefList Class Reference

BaseRefList Class Reference

A class to create BaseRefLists of Listable objects. More...

#include <BaseRefList.h>

Inheritance diagram for BaseRefList:

Inheritance graph
[legend]
List of all members.

Public Member Functions

void _del (RefWrapper *ref)
 This function is used by TypedBaseRefMap<S,T> so it made public.
 BaseRefList ()
 BaseRefList (const BaseRefList &l)
virtual ~BaseRefList ()
void print (ostream &out, char *sep) const
 print list to out with 'sep' sepperating each element
void modify (int loc, Listable &el)
 change the reference at loc to a reference to el.
void ins (const Listable &new_element, int loc)
 Insert new_element at location loc, where 0 <= loc <= entries().
void del (Listable &el, int loc)
 Delete node 'el' if on or after locth position.
virtual void del (int loc)
 Random Access Delete.
void ins_before (const Listable &new_element, const Listable &ref)
 Insert new_element before the reference element 'ref' (if ref == 0, insert at END of list).
void ins_after (const Listable &new_element, const Listable &ref)
 Insert new_element after the reference element 'ref' (if ref == 0, insert at BEGINNING of list).
BaseRefListoperator= (const BaseRefList &l)
 Copy operator copies all valid references.

Protected Member Functions

RefWrapper_find_wrapper (const Listable &el)
RefWrapper_find_wrapper (int loc)
void _ins_before (const Listable &el, const RefWrapper *ref, char *method)

Friends

class BaseRefMap
ostream & operator<< (ostream &o, const BaseRefList &l)

Detailed Description

A class to create BaseRefLists of Listable objects.

Polaris C++ VDL

See also:
BaseRefList.h

BaseRefList.h

BaseRefList.cc

Overview

The BaseRefList class creates the underlying structure for reflists for the type 'obj' which must be derived from Listable. Since the BaseRefList is derived from Collection it works with Iterators. For an object to be placed into a RefList it must have already been placed in an ownership structure like a List, Map or element. This class is not meant to be used directly but is used to build usable structures like RefList and RefSet.

Description

The BaseRefList supports all of the functionality of the structures intended for use by the public, however, since the class is not templatized, it cannot provide all of the error checking facilities which may be desired. Although, all functionality herein is duplicated in the final classes, it is still described here:

All objects in a RefList must exist in some other live structure. If this is not the case, an error is raised upon insertion. If the live object is removed from its owner-structure, references to it within the RefList will become invalid.

BaseRefList is subject to the restrictions of the Iterators--that is, when a wrapper is taken out of the BaseRefList, only the pointers of the neighboring wrappers are changed--the out-going pointers are maintained (ie, _unlink_wrapper is called).

It is possible to have more than one reference to a single object within a BaseRefList. This could cause confusion in terms of how the methods behave. If an object (it's address) is used as a reference point for a method and more than one exist, the first one encountered will be operated on.

Hierarchy Structure

Final collections do not actually inherit from BaseRefList. Instead the final collections simply contain BaseRefLists. The hierarchy can be represented by:

                        --- :    inherited from relationship
                        -c- :    contained in relationship
   
   
                            Collection
                           /          \                                          //
                          /            \                                         //
                  BaseList   Listable   BaseRefList
                  |  \          |             /  |
                  |   \         |            /   |
                  |    c  TypedCollection   c    |
                  |     \     /     \      /     |
                  |      \   /       \    /      |
                  |      LIST        RefList     |
                  |      Set         RefSet      |
                  c                              c
                  |          Listable            |
                  |             |                |
                  |             |                |
                  |        BaseMapRoot           |
                  |       /           \          |
                  |      /             \         |
                  BaseMap               BaseRefMap
                     |                       |
                     |                       |                            
                TypedBaseMap          TypedBaseRefMap
                  /     \                /         \                             //
                 /       \              /           \                            //
       ProtoDatabase      ProtoMap   ProtoRefMap    ProtoRefDatabase
            /  \           |    |      |     |         |         \               //
           /    \          |    |      |     |         |          \              //
    Database KeyDatabase  Map KeyMap  RefMap KeyMap  RefDatabase RefKeyDatabase

.BUGS Currently, RefLists are not equipped to be static.

See Also

Collection, Listable, RefWrapper, Iterator, TypedCollection, Zombie, RefList, RefSet

Definition at line 114 of file BaseRefList.h.


Constructor & Destructor Documentation

BaseRefList::BaseRefList  )  [inline]
 

< nothing to do

Definition at line 170 of file BaseRefList.h.

BaseRefList::BaseRefList const BaseRefList l  ) 
 

Definition at line 17 of file BaseRefList.cc.

BaseRefList::~BaseRefList  )  [virtual]
 

... Nothing to do.

Definition at line 25 of file BaseRefList.cc.


Member Function Documentation

RefWrapper * BaseRefList::_find_wrapper const Listable el  )  [protected]
 

Definition at line 101 of file BaseRefList.cc.

References Wrapper::next_ref().

Referenced by del(), ins(), ins_after(), ins_before(), and modify().

RefWrapper * BaseRefList::_find_wrapper int  loc  )  [protected]
 

Definition at line 111 of file BaseRefList.cc.

References Wrapper::next_ref().

void BaseRefList::_ins_before const Listable el,
const RefWrapper ref,
char *  method
[protected]
 

... gain ref from _first and _last

... insert at end

... INC BEFORE DEC

... new last gains ref

... old last looses ref

... Insert at beginning

... INC BEFORE DEC

... new first gains ref

... old first looses ref

Definition at line 130 of file BaseRefList.cc.

References Wrapper::next(), Wrapper::next_ref(), RefWrapper::object(), Wrapper::prev(), Wrapper::prev_ref(), Wrapper::ref_dec(), and Wrapper::ref_inc().

Referenced by ins(), ins_after(), and ins_before().

void BaseRefList::_del RefWrapper w  ) 
 

This function is used by TypedBaseRefMap<S,T> so it made public.

... delete first since unlink will deallocate sucka

Definition at line 181 of file BaseRefList.cc.

References Collection::_unlink_wrapper(), and Wrapper::delete_object().

Referenced by TypedBaseRefMap< S, T >::_list_delete(), TypedBaseRefMap< S, T >::_list_remove(), and del().

void BaseRefList::print ostream &  out,
char *  sep
const [virtual]
 

print list to out with 'sep' sepperating each element

Reimplemented from Collection.

Definition at line 31 of file BaseRefList.cc.

References Collection::print().

Referenced by RefSet< T >::print(), and RefList< T >::print().

void BaseRefList::modify int  loc,
Listable el
[inline]
 

change the reference at loc to a reference to el.

Definition at line 183 of file BaseRefList.h.

References _find_wrapper(), and RefWrapper::object().

Referenced by RefSet< T >::_modify(), RefSet< T >::ins(), and RefList< T >::modify().

void BaseRefList::ins const Listable new_element,
int  loc
 

Insert new_element at location loc, where 0 <= loc <= entries().

Definition at line 41 of file BaseRefList.cc.

References Collection::_check_subscript(), _find_wrapper(), and _ins_before().

Referenced by RefSet< T >::ins(), RefList< T >::ins(), RefList< T >::ins_first(), RefList< T >::ins_last(), and operator=().

void BaseRefList::del Listable el,
int  loc
 

Delete node 'el' if on or after locth position.

el MUST be in the list (this is not necessarily checked).

Definition at line 60 of file BaseRefList.cc.

References _del(), _find_wrapper(), Wrapper::next_ref(), and ProtoWrapper::object_address().

Referenced by RefSet< T >::_del(), RefSet< T >::_modify(), RefSet< T >::del(), RefList< T >::del(), and RefSet< T >::grab().

void BaseRefList::del int  loc  )  [virtual]
 

Random Access Delete.

Delete the Node in position loc where 0 <= loc < entries()-1.

Implements Collection.

Definition at line 52 of file BaseRefList.cc.

References Collection::_check_subscript(), _del(), and _find_wrapper().

void BaseRefList::ins_before const Listable new_element,
const Listable ref
[inline]
 

Insert new_element before the reference element 'ref' (if ref == 0, insert at END of list).

ref MUST be in the list (this is not necessarily checked).

Definition at line 176 of file BaseRefList.h.

References _find_wrapper(), and _ins_before().

Referenced by RefList< T >::ins_before().

void BaseRefList::ins_after const Listable new_element,
const Listable ref
 

Insert new_element after the reference element 'ref' (if ref == 0, insert at BEGINNING of list).

ref MUST be in the list (this is not necessarily checked).

Definition at line 72 of file BaseRefList.cc.

References _find_wrapper(), and _ins_before().

Referenced by RefList< T >::ins_after().

BaseRefList & BaseRefList::operator= const BaseRefList l  ) 
 

Copy operator copies all valid references.

... check for bogus assignment

... Copy only valid elements

Definition at line 83 of file BaseRefList.cc.

References Collection::clear(), BaseIter::current(), ins(), BaseIter::next(), and BaseIter::valid().


Friends And Related Function Documentation

friend class BaseRefMap [friend]
 

Definition at line 115 of file BaseRefList.h.

ostream& operator<< ostream &  o,
const BaseRefList l
[friend]
 

Definition at line 11 of file BaseRefList.cc.


The documentation for this class was generated from the following files:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:01 2005