Listing 1 This code fragment comes from a program with a collection that contains numbered items visited in ascending item-number order. The program also includes a separate array whose elements give a range of item numbers that the program logically deletes from the collection without physically removing them. The program traverses the collection, but skips over deleted items

typedef struct { int DelFrom , DelThru } DelTyp;
#define DelsMax 20
DelTyp Dels [ DelsMax ];
DelTyp * DelPtr = Dels;
DelTyp * DelMaxPtr = Dels + DelsMax;

BOOL CheckDeleted
    ( ItemNo )
      int ItemNo;

    { if ( DelPtr < DelMaxPtr
          /* There is a deletion */
          && DelPtr -> DelFrom >= ItemNo )
            /* and it applies to ItemNo */
      { assert ( ItemNo <= DelPtr -> DelThru )
        /* We didn't slip past this deletion. */
        if ( ItemNo == DelPtr -> DelThru )
            /* ItemNo is the last covered by the deletion */
          Del Ptr ++;
          /*  Consume the deletion. */
        return TRUE;
      }
      else return FALSE;
    }

/* End of File */