Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
morkNodeMapIter Class Reference

#include <morkNodeMap.h>

Inheritance diagram for morkNodeMapIter:
Inheritance graph
[legend]
Collaboration diagram for morkNodeMapIter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 morkNodeMapIter (morkEnv *ev, morkNodeMap *ioMap)
 morkNodeMapIter ()
void InitNodeMapIter (morkEnv *ev, morkNodeMap *ioMap)
mork_changeFirstNode (morkEnv *ev, mork_token *outToken, morkNode **outNode)
mork_changeNextNode (morkEnv *ev, mork_token *outToken, morkNode **outNode)
mork_changeHereNode (morkEnv *ev, mork_token *outToken, morkNode **outNode)
mork_changeCutHereNode (morkEnv *ev, mork_token *outToken, morkNode **outNode)
void CloseMapIter (morkEnv *ev)

Protected Member Functions

void InitMapIter (morkEnv *ev, morkMap *ioMap)
mork_changeFirst (morkEnv *ev, void *outKey, void *outVal)
mork_changeNext (morkEnv *ev, void *outKey, void *outVal)
mork_changeHere (morkEnv *ev, void *outKey, void *outVal)
mork_changeCutHere (morkEnv *ev, void *outKey, void *outVal)

Protected Attributes

morkMapmMapIter_Map
mork_seed mMapIter_Seed
morkAssoc ** mMapIter_Bucket
morkAssoc ** mMapIter_AssocRef
morkAssocmMapIter_Assoc
morkAssocmMapIter_Next

Detailed Description

Definition at line 101 of file morkNodeMap.h.


Constructor & Destructor Documentation

morkNodeMapIter::morkNodeMapIter ( morkEnv ev,
morkNodeMap ioMap 
) [inline]

Definition at line 104 of file morkNodeMap.h.

  : morkMapIter(ev, ioMap) { }

Definition at line 107 of file morkNodeMap.h.

: morkMapIter()  { }

Member Function Documentation

void morkMapIter::CloseMapIter ( morkEnv ev) [inherited]

Definition at line 770 of file morkMap.cpp.

Here is the caller graph for this function:

mork_change * morkMapIter::CutHere ( morkEnv ev,
void outKey,
void outVal 
) [protected, inherited]

Definition at line 919 of file morkMap.cpp.

{
  mork_change* outCutHere = 0;
  morkMap* map = mMapIter_Map;
  
  if ( map && map->GoodMap() ) /* map looks good? */
  {
    if ( mMapIter_Seed == map->mMap_Seed ) /* in sync? */
    {
      morkAssoc* here = mMapIter_Assoc; /* current assoc */
      if ( here ) /* iteration is not yet concluded? */
      {
        morkAssoc** ref = mMapIter_AssocRef;
        if ( *ref != mMapIter_Next ) /* not already cut? */
        {
          mork_pos i = here - map->mMap_Assocs;
          mork_change* c = map->mMap_Changes;
          outCutHere = ( c )? (c + i) : map->FormDummyChange();
          if ( outKey || outVal )
            map->get_assoc(outKey, outVal, i);
            
          map->push_free_assoc(here); /* add to free list */
          *ref = mMapIter_Next; /* unlink here from bucket list */
          
          /* note the map has changed, but we are still in sync: */
          mMapIter_Seed = ++map->mMap_Seed; /* sync */
          
          if ( map->mMap_Fill ) /* still has nonzero value? */
            --map->mMap_Fill; /* one less member in the collection */
          else
            map->NewSlotsUnderflowWarning(ev);
        }
      }
    }
    else map->NewIterOutOfSyncError(ev);
  }
  else map->NewBadMapError(ev);
  
  return outCutHere;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_change* morkNodeMapIter::CutHereNode ( morkEnv ev,
mork_token outToken,
morkNode **  outNode 
) [inline]

Definition at line 124 of file morkNodeMap.h.

  { return this->CutHere(ev, outToken, outNode); }

Here is the call graph for this function:

Here is the caller graph for this function:

mork_change * morkMapIter::First ( morkEnv ev,
void outKey,
void outVal 
) [protected, inherited]

Definition at line 783 of file morkMap.cpp.

{
  mork_change* outFirst = 0;
  
  morkMap* map = mMapIter_Map;
  
  if ( map && map->GoodMap() ) /* map looks good? */
  {
    morkAssoc** bucket = map->mMap_Buckets;
    morkAssoc** end = bucket + map->mMap_Slots; /* one past last */
 
    mMapIter_Seed = map->mMap_Seed; /* sync the seeds */
   
    while ( bucket < end ) /* another bucket in which to look for assocs? */
    {
      morkAssoc* assoc = *bucket++;
      if ( assoc ) /* found the first map assoc in use? */
      {
        mork_pos i = assoc - map->mMap_Assocs;
        mork_change* c = map->mMap_Changes;
        outFirst = ( c )? (c + i) : map->FormDummyChange();
        
        mMapIter_Assoc = assoc; /* current assoc in iteration */
        mMapIter_Next = assoc->mAssoc_Next; /* more in bucket */
        mMapIter_Bucket = --bucket; /* bucket for this assoc */
        mMapIter_AssocRef = bucket; /* slot referencing assoc */
        
        map->get_assoc(outKey, outVal, i);
          
        break; /* end while loop */
      }
    }
  }
  else map->NewBadMapError(ev);

  return outFirst;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_change* morkNodeMapIter::FirstNode ( morkEnv ev,
mork_token outToken,
morkNode **  outNode 
) [inline]

Definition at line 112 of file morkNodeMap.h.

  { return this->First(ev, outToken, outNode); }

Here is the call graph for this function:

Here is the caller graph for this function:

mork_change * morkMapIter::Here ( morkEnv ev,
void outKey,
void outVal 
) [protected, inherited]

Definition at line 891 of file morkMap.cpp.

{
  mork_change* outHere = 0;
  
  morkMap* map = mMapIter_Map;
  
  if ( map && map->GoodMap() ) /* map looks good? */
  {
    if ( mMapIter_Seed == map->mMap_Seed ) /* in sync? */
    {
      morkAssoc* here = mMapIter_Assoc; /* current assoc */
      if ( here ) /* iteration is not yet concluded? */
      {
        mork_pos i = here - map->mMap_Assocs;
        mork_change* c = map->mMap_Changes;
        outHere = ( c )? (c + i) : map->FormDummyChange();
          
        map->get_assoc(outKey, outVal, i);
      }
    }
    else map->NewIterOutOfSyncError(ev);
  }
  else map->NewBadMapError(ev);
  
  return outHere;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_change* morkNodeMapIter::HereNode ( morkEnv ev,
mork_token outToken,
morkNode **  outNode 
) [inline]

Definition at line 120 of file morkNodeMap.h.

  { return this->Here(ev, outToken, outNode); }

Here is the call graph for this function:

void morkMapIter::InitMapIter ( morkEnv ev,
morkMap ioMap 
) [protected, inherited]

Definition at line 726 of file morkMap.cpp.

{
  mMapIter_Map = 0;
  mMapIter_Seed = 0;

  mMapIter_Bucket = 0;
  mMapIter_AssocRef = 0;
  mMapIter_Assoc = 0;
  mMapIter_Next = 0;

  if ( ioMap )
  {
    if ( ioMap->GoodMap() )
    {
      mMapIter_Map = ioMap;
      mMapIter_Seed = ioMap->mMap_Seed;
    }
    else ioMap->NewBadMapError(ev);
  }
  else ev->NilPointerError();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void morkNodeMapIter::InitNodeMapIter ( morkEnv ev,
morkNodeMap ioMap 
) [inline]

Definition at line 108 of file morkNodeMap.h.

  { this->InitMapIter(ev, ioMap); }

Here is the call graph for this function:

mork_change * morkMapIter::Next ( morkEnv ev,
void outKey,
void outVal 
) [protected, inherited]

Definition at line 822 of file morkMap.cpp.

{
  mork_change* outNext = 0;
  
  morkMap* map = mMapIter_Map;
  
  if ( map && map->GoodMap() ) /* map looks good? */
  {
    if ( mMapIter_Seed == map->mMap_Seed ) /* in sync? */
    {
      morkAssoc* here = mMapIter_Assoc; /* current assoc */
      if ( here ) /* iteration is not yet concluded? */
      {
        morkAssoc* next = mMapIter_Next;
        morkAssoc* assoc = next; /* default new mMapIter_Assoc */  
        if ( next ) /* there are more assocs in the same bucket after Here? */
        {
          morkAssoc** ref = mMapIter_AssocRef;
          
          /* (*HereRef) equals Here, except when Here has been cut, after
          ** which (*HereRef) always equals Next.  So if (*HereRef) is not
          ** equal to Next, then HereRef still needs to be updated to point
          ** somewhere else other than Here.  Otherwise it is fine.
          */
          if ( *ref != next ) /* Here was not cut? must update HereRef? */
            mMapIter_AssocRef = &here->mAssoc_Next;
            
          mMapIter_Next = next->mAssoc_Next;
        }
        else /* look for the next assoc in the next nonempty bucket */
        {
          morkAssoc** bucket = map->mMap_Buckets;
          morkAssoc** end = bucket + map->mMap_Slots; /* beyond */
          mMapIter_Assoc = 0; /* default to no more assocs */
          bucket = mMapIter_Bucket; /* last exhausted bucket */
          mMapIter_Assoc = 0; /* default to iteration ended */
          
          while ( ++bucket < end ) /* another bucket to search for assocs? */
          {
            assoc = *bucket;
            if ( assoc ) /* found another map assoc in use? */
            {
              mMapIter_Bucket = bucket;
              mMapIter_AssocRef = bucket; /* ref to assoc */
              mMapIter_Next = assoc->mAssoc_Next; /* more */
              
              break; /* end while loop */
            }
          }
        }
        if ( assoc ) /* did we find another assoc in the iteration? */
        {
          mMapIter_Assoc = assoc; /* current assoc */
          mork_pos i = assoc - map->mMap_Assocs;
          mork_change* c = map->mMap_Changes;
          outNext = ( c )? (c + i) : map->FormDummyChange();
        
          map->get_assoc( outKey, outVal, i);
        }
      }
    }
    else map->NewIterOutOfSyncError(ev);
  }
  else map->NewBadMapError(ev);
  
  return outNext;
}

Here is the call graph for this function:

Here is the caller graph for this function:

mork_change* morkNodeMapIter::NextNode ( morkEnv ev,
mork_token outToken,
morkNode **  outNode 
) [inline]

Definition at line 116 of file morkNodeMap.h.

  { return this->Next(ev, outToken, outNode); }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

morkAssoc* morkMapIter::mMapIter_Assoc [protected, inherited]

Definition at line 367 of file morkMap.h.

morkAssoc** morkMapIter::mMapIter_AssocRef [protected, inherited]

Definition at line 366 of file morkMap.h.

morkAssoc** morkMapIter::mMapIter_Bucket [protected, inherited]

Definition at line 365 of file morkMap.h.

morkMap* morkMapIter::mMapIter_Map [protected, inherited]

Definition at line 362 of file morkMap.h.

morkAssoc* morkMapIter::mMapIter_Next [protected, inherited]

Definition at line 368 of file morkMap.h.

mork_seed morkMapIter::mMapIter_Seed [protected, inherited]

Definition at line 363 of file morkMap.h.


The documentation for this class was generated from the following file: