
Заготовки по С / Динамические структуры / GDSL / Документация
.pdf
|
4.13 Queue manipulation module |
|
157 |
|||||
|
Returns: |
|
|
|
|
|
||
|
the modi ed queue ase of su ess. |
|
||||||
|
NULL in ase of insu ient memory. |
|
||||||
See also: |
|
|
|
|
|
|||
|
gdsl_queue_get_name()(p. 154) |
|
||||||
4.13.2.10 |
gdsl_element_t gdsl_queue_insert (gdsl_queue_t Q, |
|||||||
|
AInsertLLOClloComplexitnewateanaelemenFnewmenisvoidy:theO(ElemeninfunisVALUEa1thenqueue)ionEinsertedbypointer(PUT)alling.atpassthQ'sedheaderALLOCtogdslpositionFqueuefunof tionthealloqueueon()VALUE(pQ.153). . |
|||||||
Note:The |
|
|
|
|
|
|
|
|
|
re ondition: |
|
|
|
|
|||
|
|
|
ust be a valid gdsl_queue_t |
|
|
|||
Parameters: |
|
|
|
|
||||
|
Q |
The queue to insert in |
|
|
|
|||
|
VALUE The value used to make the new element to insert into Q |
|
||||||
Returns: |
|
lement E |
ase of su ess. |
|
||||
|
the |
|
|
|
||||
|
NULLinsertedase of insu ient memory. |
|
||||||
See also: |
|
|
|
|
|
|||
|
gdsl_queue_remove()(p. 157) |
queue_remove (gdsl_queue_t Q) |
||||||
4.13.2.11 |
gdsl element |
t gdsl |
||||||
|
|
|
an |
|
t from a queue (GET). |
|
||
|
Remove theelement at the footer position of the queue Q. |
|
||||||
Note: |
|
|
|
|
|
|
|
|
|
re ondition:y: O( 1 ) |
|
|
|
||||
|
Complexitust be a valid gdsl_queue_t |
|
|
|||||
Parameters: |
to remove the tail from |
|
||||||
|
Q |
The |
|
|
||||
|
Generated onqueueTh Jun 22 11:15:30 2006 for gdsl by Doxygen |
|

158 |
|
|
|
|
gdsl Module Do umentation |
|
|
Returns: |
|
|
|
|
|
|
|
the removed |
lement in ase of su ess. |
|
||
|
|
NULL in ase of Q is empty. |
|
|
||
See also: |
|
|
|
|
||
|
|
gdsl_queue_insert()(p. 157) |
_queue s ar h |
|||
4.13.2.12 |
|
elem nt_t |
||||
|
|
|
gdsl_queue t Q,gdsl_ ompare fun ( onstCOMP_F, void |
Note:COMPSearComplexith forFatothepartiVALUEy:omparrstO(ulareelemenall) Q'st tEelementinequalqueuewithto.VALUE. in the queue Q, by using
Parameters:reCOMP |
|
|
elemenus d_toF !=ompareNULLQ's element with |
||
Qondition:TheustVALUEqueuebeFa Thevalidto|searQgdslomparison| / h2 the)queueelemenfun&tioCOMPin |
|||||
VALUE The value to ompare Q's |
|
ts with |
|||
Returns: |
|
|
|
|
|
the rst founded element E in ase of su ess. |
|||||
NULL in ase the sear hed elemen |
E was not found. |
||||
See also: |
|
|
|
|
|
gdsl_queue_sear h_by_position(p. 158) |
|||||
4.13.2.13 |
elem nt gdsl |
queue |
sear h_by_position ( onst |
||
|
gdsl_queue |
t Q, ulong POS) |
|
||
Sear h for an element by its position |
in a queue. |
Note:
Pre QComplexitondition:ust bey:a O(valid|Qgdsl| / 2_)queue_t & POS
Generated on Thu Jun 22>11:15:30&POS2006<for= |gdslQ| by Doxygen

|
4.13 Queue manipulation module |
|
159 |
||
|
Parameters: |
|
|
|
|
|
Q The queue to sear |
the elem t in |
to sear h |
|
|
|
POS The position where is the elemen |
|
|||
Returns: |
|
|
|
|
|
|
the element at the POS-th position in the queue Q. |
|
|||
See4.13gdslNULLalso:.2.14 queueif |
> | | |
< |
|
|
|
|
gdslPOS__queuelemsearL eorh()ntPOSt(pQt.,158)gdslgdsl= 0.queuemap_funmap_tforwardMAP_F( ,onstvoid |
|
Note:returnsGDSLParsealled aonllitsMAPqueueelementsealastUSERh fromQ'sSTOP,examinatofelemheadtheDATAentodqueuenelementgdslwithtail) .QUSERqueuefrom. headDATAmapto argumenttailforward(). The. MAPIf(pMAP.159)F_funstopsFreturntionandis
QComplexitondition:Theust queuebeFDAy:TheaO(validtoAmapparseQUser'sgdsl)fun datasqueuetiontopassedtapply&MAPreturnso MAPeaF h!=Q'sFNULLelement |
|
|||
Parameters:reUSERMAP |
| | |
|
|
|
Returns: |
|
for whi h MAP_F |
GDSL_MAP_STOP. |
|
the rst elemen |
|
|||
NULL when the parsing is done. |
|
|
||
See also: |
|
|
|
|
gdsl_queue_map_ba kward()(p. 159) |
map ba kward ( onst |
|
||
4.13.2.15 |
elem nt_t gdsl_queue |
|
||
|
gdslThufromJunqueutail22DATAto11:15:30e headt)Q.,2006gdslfor_mapgdsl by_funDoxygent MAP_F, void |
|
||
GeneratedParse queueon USER |
|
|
||
|
|
|
|
|

160 |
|
|
|
|
|
gdsl Module Do umentation |
|||
Parse all elements of the queue Q from |
|
to head. The MAP F fun - |
|
||||||
tion is alled on ea h Q's elemen |
with USER |
DATA argument. If MAP F |
|||||||
st ps and returns its last examinated elementail. |
|
|
|
||||||
returns GDSL |
MAP |
STOP, then gdsl queue map ba kward()(p. 159) |
|||||||
Note: |
|
|
|
|
|
|
|
|
|
QComplexitondition:Theust queuebeFDATy:TahO(validetoMAPmapparseQUser'sgdsl)fun datasqueuetiontopassedtapply&MAPtoonMAPeaF h!=Q'sFNULLRelementurnsthe rst element |
|||||||||
Parameters:reUSERMAP |
|
| |
| |
|
|
|
|
|
|
for whi |
|
|
F returns GDSL_ |
|
_STOP. Returns NULL when |
||||
See also:the parsing is done. |
|
|
|
|
|
||||
gdsl_queue_map_forward()(p. 159) |
|
|
|
|
|||||
4.13.2.16 void gdsl_qu ue_ |
( onst gdsl_queue_t |
||||||||
|
|
|
writeFILEfun,voidwriteWRITE_F, FILE |
|
|||||
OUTPUTQ, gdsl |
|
|
|
|
Note:tionWrite.Complexity:AdditionnalthealltheelemeneltsO(USERoftstheof_aqueueDATAqueueQargumentotoOUTPUTle.USERt ould_FILE,beDATApassedusing) toWRITE__FFfun. -
PreParameters:QWRITEQWRITEondition:TheustqueueFbeF!=aThetoNULLvalid|writeQwrite| ) .gdslfun queuetion._t & OUTPUT_FILE != NULL & OUTPUT FILE The le where to write Q's elements.
USER DATAwriteUs r's datas(passed to WRITE F.
See gdslalso:_queue_dump()xml()(p. 161) . 161)
Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

Queue manipu ation module |
_xml ( onst gdsl_queue_t |
161 |
|
4.13.2.17 void gdsl_qu ue_ |
|
||
e fun,voidwriteWRITE_F, FILE |
|
|
|
OUTPUTQ, gdsl writFILE |
|
|
Note:IfOUTPUTWRITEriteWRITEComplexittheFelementsontentFILEy:!=.O(ofAdditionnalNULL,ofaqu. theuequeuethentoUSERausesQletointoWRITEOUDAUSERXMLPUTA.argumenFDATAFILE,towrite)intoouldQ'sXMLbelemenpassednguagetsto.
Parameters:reOUTPUTWRITEQondition:Theust queuebeFa validFILEThetowrite()|Qgdsl| )The.queuefunle tionwheret.&toOUTPUTwriteQ's FILEelements!=.NULL
USER_DATA Us r's datas passed to WRITE_F.
See gdslalso:_queue_dump()(p(p..160)161)
4.13.2.18 void gdsl_qu ue_dump ( onst gdsl_queue_t OUTPUTQ, gdsl writFILEe fun,voidt WRITE_F, FILE
Note:ditionnalDumpULL,Complexity:thethenUSERinstruusesernaltureO(DAWRITEstruofAtureargumentheFofqueuetoawritequeueouldQtoQ'stobeUSEROUTPUTaelempassle.edntsDATAtotoFILEWRITEOUTPUT). If WRITEF.FILE.FAd!=-
Parameters:re WRITEOUTPUTQondition:Theust queuebeFa validFILETheto|writeQgdslwrite| )The.queuefunle tionwheret.&toOUTPUTwriteQ's FILEelements!=.NULL
Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

162 |
|
|
gdsl Module Do umentation |
|
|
USER_DATA Us r's datas passed to WRITE_F. |
|
||
See also: |
()(p. 160) |
|
|
|
|
gdsl_queue_write |
|
|
|
|
xml()(p. 161) |
|
|
Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

.14 Red-bla k tree manipulation mod le |
|
163 |
||||
4.14 Red-bla k tree manipulation module |
|
|||||
T |
|
|
|
|
|
|
Funypedefsˆˆ gdsltionsrbtreegdslrbtreerbtreegdslgdslrbtreerbtreeallot ( onst har |
|
|
||||
|
|
|
|
|
F, |
|
|
afunteoyaanewfund-blaALLdt-blakCOMPfreetrushk .(gdsl(F,gdsl. F)gdslrbtreerbtreefree___ttfunT)T) _t FREENAME, gdsl_- |
|||||
|
gdsl |
|
|
|
|
|
|
voidalloompDestrCr |
|
|
|
|
|
|
Flush a r d-bla k tr . |
|
|
|
|
|
ˆ |
rbtreerbtreedof-ofblaaekgdslistr-dgetbla-blaeemptiskrbtreeknamesizeemptytr . .(. onst(getonstgdslrootgdsl__rbtree(rbtreeonst__tgdslT)t T)_rbtree_t |
|||||
|
T)gdslboolharCheGetgdslelemengdslthekifrootname |
|
|
|
|
|
|
ulong gdsl |
get |
|
( onst gdsl_rbtree_t T) |
|
|
|
heigh |
( onst gdsl_rbtree_t T) |
|
|
||
|
size of a |
-bla k |
. |
. |
|
|
ˆ |
Get the height of a re -bla k |
|
|
|
||
gdsl rbtree gdsl_ |
_set_name (gdsl_rbtree_t T, onst |
|||||
ˆ |
elementhe nameelementNAME)of a regdsl-blarbtreerbtreek._insert (gdsl_rbtreeturn T, |
void |
||||
|
gdslharSetNEW |
|
|
|
|
|
ˆ |
|
|
|
remoif it'sve not(gdslfound or _t itT,. |
void |
|
|
gdslVALUE,Insertelemenanin RESULT)gdslinto a r d-bla k_tr |
|
|
GeneratedVALUE)Removeon ThuanJunelement22 11:15:30from 2006a dfor-blagdslk trby.Doxygen

164 |
|
gdsl Module Do umentation |
ˆ gdsl_rbtree_ gdsl_ |
_ |
(gdsl_rbtree_t T, void |
ˆ gdslVALUE)Deleteelemenomparean elementartifungdslularfromelementarbtreeCOMPd-bla kdeleteF,seartr v.oidh ( onst gdsl_rbtree_t T,
ˆgdslgdslT, Searelemenh forapt__fungdslt_MAPrbtreeF,intomapvoid _-preblaVALUE)k xtree( .onst gdsl_rbtree_t
ˆgdslgdslT, Parse_ apd-blat funtk treegdsltin_MAPpre xedF,_ordervoidmap. _USERin x_(DATA)onst gdsl_rbtree_t
ˆ rbtreegdslParse_ta T,r d-gdslblat tk_treemapgdslin_infunrbtreexed orderMAPmap. USERF,postvoidDATA)x ( onst gdsl_-
ˆvoidfunParseritegdslWRITEa rrbtreed-bla kF,_trwriteFILEin post( onstxed ordergdsl._rbtreerbtreeUSERT,gdslDATA)write_-
ˆvoidwriteW gdslfunthe_rbelementontentreeWRITEof a hF,nodeOUTPUTxmlFILEof a( reonst-blaFILE,gdslk voidto aUSERle. t_DATA)T, gdsl
ˆDATA)voidfunWritegdslWRITEtherbtreeF,ofdumpFILEa re -bla( onstk treegdsltoOUTPUTa lerbtreeinto XMLFILE,t T,. voidgdsl writeUSER__--
4..14.1.1.1DumpTtypedefthe internalstruDotstruumentationgdsltureOUTPUTrbtreeof a red-blaFILE,k tovoida leUSER. _DATA)
GDSLThisDebut nitionbyyperedthe-isatblafunvoluntarylinektionstree52ofypeGeneratedopaquethisle.gdslmodule.Variablesrbtreeon .Thu.hJun.of thisgdsl22 11:15:30kindrbtreeould'nt2006 tforbegdsldireby Doxygently used,

. Red-bla k tree manipulation m dule |
165 |
. .2 Fun tion Do umentation |
|
4.14ould.toate2..a1respeTheanewbeFREEgdslnewsetfunredtively,tored-tionblaallorbtreeNULL-blaFallok,pointersgdsltreek,funtoftree. usegdslanddataALLOComparettheALLOCrbtreeomparesstrudefaultF,turefunFREEonalloelFwhie,argumens:gdslt COMP(htsFonstnameinandfreetheCOMPishartreeFfunset) . toTheseNAMEFta ouldopypoint, beof- |
|||||||||||
ersusedNAMEAlloCreate |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ALLOC |
F simply returns its |
t |
|
|||
ˆ the default |
FREE |
F does nothing |
|
|
|||||||
COMP_F always returns 0 |
|
|
|||||||||
Note: |
|
|
|
|
|
|
|
|
|
|
|
Complexity: O( 1 ) |
|
|
|
|
|
||||||
re ondition: |
|
|
|
|
|
|
|
|
|||
nothing |
|
|
|
|
|
|
|
|
|
||
Parameters: |
|
|
|
|
f the new |
-bla k tr |
to eate |
|
|||
NAME The name |
|
||||||||||
FREE F F |
|
to free elemred t when removing it from a r-b tree |
|||||||||
COMP_F Fun tion to ompare elements intoinsertingthe -b tree |
|||||||||||
ALLOC |
|
F F |
|
n to allo |
t wh |
|
it in a r- |
||||
Returns: |
|
|
llo ated red-bla k tree in ase of su ess. |
|
|||||||
the newly |
|
|
|||||||||
NULL in |
ase of failure. |
|
|
|
|
||||||
See also: |
|
|
|
|
free()(p. 165) |
|
|
|
|||
gdsl_rbtree_ ush()(p. 166) |
|
|
|
||||||||
4.14.2.2 |
|
void gdsl rbtree_free (gdsl_rbtree_t T) |
|
||||||||
stroy |
|
red-bla k tree. |
|
|
|
by alling T's FREE F |
|||||
Deallo ate |
the elements f the red-bla k tree |
||||||||||
and T is |
deallo ated itself too. |
allo ()(p. 165). |
The name of T is deallo ated |
||||||||
fun tion passed to gdsl rbtree |
|||||||||||
Note: |
|
|
|
|
|
|
|
|
|
|
|
GeneratedComplexity:on Thu JunO( |22T|11:15:30) |
2006 for gdsl by Doxygen |
|
|||||||||
|
|
|
|
|
|
|
|
|
|
|
|

166 |
|
|
|
|
|
gdsl Module Do umentation |
re ondition: |
|
|
|
|
||
Parameters:ust be a valid gdsl_rbtree |
|
|||||
|
T The red-bla k tree to deallo ate |
|
||||
See also: |
|
allo |
|
|||
|
gdsl_rbtree_ ush()(p.165)6 |
|
||||
4.14.2.3 |
void gdsl |
. |
rbtree_ ush (gdsl_rbtree_t T) |
|||
Flush red-bla k |
|
|
|
|||
Deallo ate |
all thetreeel ments of the red-bla k tree by alling T's FREE F |
|||||
fun tion passed to gdsl rbtree allo ()(p. 165). The red-bla k tree T is not |
||||||
deallo ated itself and its name is not modi ed. |
||||||
Note: |
rbtreebey:a validO(free()alloTgdsl)()(p(p.rbtree165). _t |
|
||||
SeePre gdslTComplexitalso:ondition:ust |
| |
|
| |
|
PNote:Get4.ostarameters:re14Complexity:the.ondition:2ondi |
|
he.4nameustharbeof:a avalidO(gdslstringred1-)bladslrbtreek rbtreetree. gett_name ( onst gdsl_rbtree_t T) |
|
ur ed |
MUST NOT be freed. |
T The red-bla k tree to get the name from |
|
Returns: |
|
the name of the red-bl k tree T. |
|
See also: |
|
gdsl_rbtree_set_name()(p. 168) |
|
|
Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen |