Logo Search packages:      
Sourcecode: pbzip2 version File versions  Download package

int queue::remove ( ElementTypePtr element ) [inline]

Remove the head returning it into element. If the given element is tail of multi-segment sequence - just moves to next segment.

Parameters:
element- removed element is copied here
Returns:
1 on success; 0 - on denied request; -1 - on error

Definition at line 211 of file pbzip2.h.

      {
            ElementTypePtr & headElem = qData[head];

            #ifdef PBZIP_DEBUG
            fprintf (stderr, "queue::remove: head=%llx; elem=%llx; count=%ld\n",
                        (unsigned long long)headElem,
                        (unsigned long long)element,
                        count);

            if (headElem != NULL)
            {
                  fprintf (stderr, "  queue::remove: head: seq=%d; blk=%d; islast=%d\n",
                        headElem->sequenceNumber,
                        headElem->blockNumber,
                        (int)headElem->isLastInSequence);
            }
            
            if (element != NULL)
            {
                  fprintf (stderr, "  queue::remove: element: seq=%d; blk=%d; islast=%d\n",
                        element->sequenceNumber,
                        element->blockNumber,
                        (int)element->isLastInSequence);
            }
            #endif

            if ( (element != NULL) && !element->isLastInSequence )
            {
                  if (element->next != NULL)
                  {
                        element = element->next;
                  }
                  else
                  {
                        // 2+ part of long-sequence BZ2 stream. Next
                        // segment is not ready yet.
                        return 0;
                  }
            }
            else if (topLevelEmpty)
            {
                  return 0;
            }
            else
            {
                  element = headElem;
                  ++head;

                  if (head == size)
                        head = 0;

                  if (head == tail)
                        topLevelEmpty = 1;

                  topLevelFull = 0;
            }

            --count;
            
            if (count == 0)
                  empty = 1;

            full = 0;

            return 1;
      }

Generated by  Doxygen 1.6.0   Back to index