1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
/*
*
* Copyright (C) 1994-2011, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmnet
*
* Author: Marco Eichelberg
*
* Purpose: List class with procedural API compatible to MIR CTN
*
*/
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmnet/lst.h"
LST_HEAD::LST_HEAD()
: theList()
, theIterator()
{
theIterator = theList.end();
}
LST_HEAD::~LST_HEAD()
{
}
void LST_HEAD::push_back(void *node)
{
theList.push_back(node);
}
void *LST_HEAD::dequeue()
{
if (theList.size() == 0) return NULL;
void *result = theList.front();
theList.pop_front();
return result;
}
size_t LST_HEAD::size() const
{
return theList.size();
}
void *LST_HEAD::front()
{
if (theList.size() > 0) return theList.front();
else return NULL;
}
void *LST_HEAD::next()
{
if (theList.size() == 0) return NULL;
if (theIterator == theList.end()) return NULL;
++theIterator;
if (theIterator == theList.end()) return NULL;
return *theIterator;
}
void *LST_HEAD::current() const
{
if (theList.size() == 0) return NULL;
OFListConstIterator(void *) it = theIterator;
if (it == theList.end()) return NULL;
return *theIterator;
}
void *LST_HEAD::position(void *node)
{
OFListIterator(void *) first = theList.begin();
OFListIterator(void *) last = theList.end();
while (first != last)
{
if (*first == node)
{
theIterator = first;
return node;
}
++first;
}
theIterator = last;
return NULL;
}
/*******************************************************/
LST_HEAD *LST_Create()
{
return new LST_HEAD();
}
void LST_Destroy(LST_HEAD **lst)
{
delete *lst;
*lst = NULL;
}
void LST_Enqueue(LST_HEAD **lst, void *node)
{
(*lst)->push_back(node);
}
void *LST_Dequeue(LST_HEAD **lst)
{
return (*lst)->dequeue();
}
void *LST_Pop(LST_HEAD **lst)
{
return (*lst)->dequeue();
}
unsigned long LST_Count(LST_HEAD **lst)
{
return (unsigned long)((*lst)->size());
}
void *LST_Head(LST_HEAD ** lst)
{
return (*lst)->front();
}
void *LST_Next(LST_HEAD **lst)
{
return (*lst)->next();
}
void *LST_Current(LST_HEAD **lst)
{
return (*lst)->current();
}
void *LST_Position(LST_HEAD ** lst, void *node)
{
return (*lst)->position(node);
}
|