Back to index

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

#include <morkMap.h>

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

List of all members.

Public Member Functions

 morkMapIter (morkEnv *ev, morkMap *ioMap)
void CloseMapIter (morkEnv *ev)
 morkMapIter ()

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 359 of file morkMap.h.


Constructor & Destructor Documentation

morkMapIter::morkMapIter ( morkEnv ev,
morkMap ioMap 
)

Definition at line 748 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:

Definition at line 714 of file morkMap.cpp.


Member Function Documentation

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]

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 * morkMapIter::First ( morkEnv ev,
void outKey,
void outVal 
) [protected]

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 * morkMapIter::Here ( morkEnv ev,
void outKey,
void outVal 
) [protected]

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:

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

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:

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

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:


Member Data Documentation

Definition at line 367 of file morkMap.h.

Definition at line 366 of file morkMap.h.

Definition at line 365 of file morkMap.h.

Definition at line 362 of file morkMap.h.

Definition at line 368 of file morkMap.h.

Definition at line 363 of file morkMap.h.


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