Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
20
Добавлен:
15.06.2014
Размер:
652.77 Кб
Скачать

 

Red-bla k tree manipulation module

167

 

4.14.2.5

bool gdsl

rbtree

is_empty ( onst gdsl_rbtree_t T)

 

 

Che k if a red-bla k tree is empty.

 

Note:

 

 

 

 

 

 

 

 

 

re ondition:y: O( 1 )

 

 

 

 

 

 

Complexitust be a valid gdsl_rbtree_t

 

Parameters:

 

 

 

 

 

 

 

T

The red-bla k tree to he k

 

Returns:

 

-

 

k

 

T is empty.

 

 

TRUE if

 

 

 

 

FALSE ifthered-bla ktree

T is not empty.

 

4.14.2.6

gdsl

element

gdsl_rbtree_get_root ( onst

 

 

 

 

rbtree

 

t T)

 

 

 

Get the root of a red-bla k tree.

 

 

Note:

 

 

 

 

 

 

 

 

 

re ondition:y: O( 1 )

 

 

 

 

 

 

Complexitust be a valid gdsl_rbtree_t

 

Parameters:

 

 

 

 

 

 

 

T

The red-bla k tree to get the root element from

 

Returns:

 

 

 

 

 

 

 

 

the element at the root of the red-bla k tree T.

 

4.14.2.7

ulong

 

 

rbtr e_get_size ( onst gdsl_rbtree_t T)

 

 

Get the size of a redgdsl-b a k tree.

 

 

Note:

 

 

 

 

 

 

 

 

 

Complexitust be a valid gdsl_rbtree_t

 

 

re ondition:y: O( 1 )

 

 

 

 

 

Parameters:

 

 

 

 

 

 

 

T

The red-bla k tree to get the size from

 

 

Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

 

168

gdsl Module Do umentation

Returns:

 

See4.14Get thethegdslComplexitalso:.2.8sizeheighrbtreeulongof theof agetgdslredred-height()-blablarbtreekktreetree_.Theight(noted(|Tonst|). gdsl_rbtree_t T) Note:

Parameters:retheTondition:Theheighustrbtreeredbey:-ofablavalidO(thek Tredtreegdsl)-blatorbtreekomputetreeT the(notedheighth(T))from.

Returns:

 

| |

See also:

 

_get_size()(p. 167)

gdsl_

 

4.14.2.9

gdsl_rbtree_t gdsl_rbtree_set_name (gdsl_rbtree_t T,

TComplexity:ondition:nametheustpreviousbeonstofaavalidO(redhar1name-bla)gdslNEWkoftreerbtreethe.redNAMEt-bla k)tree T to a opy of NEW_NAME.

PNote:ChangeSetarameters:rethe

 

The red-bla k tree to hange the name

NEW_NAME The new name of T

Returns:

 

the modi ed red-bla k tr in ase of su ess.

NULL in ase of insu ient memory.

See also:

 

gdsl_rbtree_get_name()(p. 166)

 

Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

 

Red-bla k tree

module

169

 

4.14.2.10

gdsl_elemen _

gdsl_rbtree_insert (gdsl_rbtree_t T,

 

 

 

 

 

elemenreandturnto-blatisndEitkinserted.isittree.alloIfT,atedEanbyis

 

 

 

passedinequalisn'tktreeRESULTfound,totoifVALUEgdslit'sthennotrbtree) foundintoanewthealloor

 

gd,rehT'santforurnedhenelementALLOCCOMPtheit'svoid. restintoFurnedFelementVALUEfunamanipulationred.tionIf-blaEE,

 

 

 

fouSearInsert

 

 

 

 

 

usi

 

 

 

then

 

 

Note:

 

 

Parameters:reRESVALTComplexitondition:TheustULTEredbeThey:-aTheblavalidO(valuekaddresslog(treegdslu|Ttoed| rbtreewhere)mt)odifymakthet &theresultRESULTnewodeel ment!=willNULLbetostoredinsert.into T

Returns:the elementRESULand RESULT = GDSL_OKERRif_EDUPLICATEis inserted intoENTRinsu. Y ienf E isNULLalreadyandpresent inT =T.GDSL_ERR MEM_ALLOC ase of t memory.

See gdslalso:_rbtree_remove()delete()(p(p. 170). 169)

4.14.2.11 gdsl_element_t gdsl_rbtree_remove (gdsl_rbtree_t T, Note:isbyRemovfound,usingComplexitfromanT'siselementvoidCOMPtheremovedy:O(redfromVALUE-logblaFfromfun(ka treeredtionT)-andblaTpassthethenk treedrsttoreturned.foundedgdsl .rbtreeelem ntalloE equal()(pto.165)VALUE,.If

PreGeneratedTondition:ust beThua Junvalid22gdsl11:15:30|T|rbtree))2006tfor gdsl by Doxygen

170

 

 

 

 

gdsl Module Do umentation

 

Parameters:

 

 

 

 

 

 

T The red-bla k tree to m

dify

 

 

 

VALUE The value used to nd the element to remove

 

 

NULL in ase no element equal to VALUE is fouind in T.

Returns:

 

t

 

in T ase is found.

 

 

the rst founded

 

See also:

ins

rt() .

69)

 

gdsl_rbtree_delete()(p.170)

4.14.2.12 gdsl_rbtree_t gdsl_rbtree_delete (gdsl_rbtree_t T,

Note:DRbyispassefound,moveleteusingComplexitantofromT'sitgdslelementisvoidCOMPremovedthey:rbtreeO(redfromVALUElog(-FblfromafunalloredkTtreeion-)blaand()thepassed(pkE.tree165),isrstdeallo.tofoundedthengdslatedTrbtreeiselemenusingreturnedT'salloE.FREEequal()(pto.F165)VfunALUE,.tionIf

Returns:Parameters:reVALUETondition:Theust redbeThe-ablavalidvaluektreegdslused|Tto| rbtreeremovetondtantheelementtfromtoremove theNULLmodiif noedelemenr dinsert()-bla equalk treetoafterVALUEremovalwasoffoundE if .E was found.

See gdslalso:_rbtree_elemenre ove()p(p. 169). 169)

4.14.2.13 gdsl_rbtree tt tT,gdslgdsl__rbtreeomparsearfunh ( onstCOMP_F, funCOMPSeartionh fortheFpassedafunpartivoidrsttielemenoulargdslVALUEtoGeneratedtelementndErbtreeequalit). inIfontoalloCOMPThuaVALUEred()Jun-(pblaF.22165)ink==11:15:30treeheisNULL,.redused2006-bla.thenfork treegdsltheT,byCOMPDoxygenby usingF

 

4.14 Red-bla k tree manipulation module

 

171

 

Note:

 

 

 

 

 

 

TComplexitondition:TheustCOMPVALUEredbeFy:-ablaThevalidO(F)toklog(treegdslomparisonndTtotherbtree)use)elemen. funt tionE to(ruseNULLtoomparetouseT'stheelemendefaultwithT's

Parameters:reCOMP

| |

 

 

 

 

VALUE The value that

ust be used by COMP_F to nd the elemen E

Returns:

 

 

 

 

 

 

the rst founded element E equal to VALUE.

 

 

 

NULL if VALUE is not found in T.

 

 

See also:

 

ins rt()

. 169)

 

 

 

 

 

remove()(p. 169)

 

 

 

gdsl_rbtree_delete()(p. 170)

 

 

4.14.2.14

 

element_t gdsl_rbtree_map_pre x ( onst

 

 

 

 

 

 

 

 

-

 

 

gdslofkelemenFstopstreehereturrbtreeDATAredinand-presontainedblareturnsGDSLt)xedkTtree, gdslorderitsMAPinTealastin.mapprehSTOP,examinatednodex funwithorderthenthetel.gdslMAPThementUSERMAPrbtree. F,DATAvoidF funmaprgution

 

alled.x()Ifred(ponnodesMAP.-171)blatheUSER

 

 

 

 

Parse

 

 

 

 

Note:premenis

 

 

 

 

Parameters:reMAPUSERComplexitTondition:Theust redbeFDAy:-TheablavalidO(Akmap|TtreeUser'sgdsl| )funtorbtreedatasmaption.. passedt&MAPtoMAPF !=FNULL Returns:the rst elemen for whi h MAP_F returns GDSL_MAP_STOP.

NULL when the parsing is done.

Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

172

 

 

 

 

gdsl Module Do umentation

 

See also:

 

 

 

 

 

 

 

 

gdsl_rbtree_map_

in x()(p. 172)

 

 

 

 

 

 

(p. 172)

 

 

4.14.2.15

elemen _

gdsl_rbtree_map_in x ( onst

 

 

 

 

 

 

 

 

 

-

 

 

 

 

gdslstopsofkelemenFtreethereturnsrbtreeandDATAredininreturns-ontainedblapostGDSLxedTk ,treeorderx()itsgdslMAPinlastT.eainmapexaminatedhinSTOP,nodexedfunwithorderthenelementtthe.gdslMAPTheUSER.MAPrbtreeF,DATAvoidF funmaprgution

 

 

x(). (pIfllredon.nodesMAP172)-blatheUSER

 

 

 

 

 

alled

 

 

 

 

 

 

 

 

 

 

 

 

 

 

inmenParses

 

 

 

 

 

Note:

 

 

 

 

TComplexity:ondition:Theust redbeFDA-TheablavalidO(AkmapTtreeUser'sgdsl)funtorbtreedatasmaption.. passedt&MAPtoMAPF !=FNULL

 

Parameters:re USERMAP

| |

 

 

 

Returns:

 

for whi h MAP_F returns GDSL_MAP_STOP.

 

the rst elemen

 

NULL when the parsing is done.

 

See also:

 

 

re x()(p. 171)

 

gdsl_rbtree_map_p

 

 

(p. 172)

 

4.14.2.16

elemen _

gdsl_rbtree_map_post x ( onst

 

 

 

 

 

 

 

-

 

 

gdsl172)ofkelemenFthtrstopsreturnsrbtreeredDATAinand-postblaontainedGDSLreturnsostkTxedtree, x()gdslorderMAPinTitsinealast.mapposthSTOP,nodexaminatedxfunwiththenordertthegdsl.elemenMAPTheUSERMAPrbtree.F,DATAvoidF funmaprgution

 

. x()IfredonnodesMAP(p-.blatheUSER

 

 

 

 

alled

 

 

 

 

 

Parse

 

 

 

 

 

postmenis

 

 

 

 

 

 

Note:

 

 

 

 

Complexity: O( |TGenerated| ) on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

4.14 Red-bla k tree

module

 

 

173

T ust be a valid gdslmanipulationrbtree & MAP_F != NULL

 

 

Prearameters:ondition:

 

 

 

 

 

T The red-bla k tree to map.

 

 

 

 

MAP F

map fun tion.

 

 

 

 

USER_DATheA User's datas passed to MAP_F

 

 

Returns:

 

for whi h MAP_F returns GDSL_MAP_STOP.

 

the rst elemen

 

NULL when the parsing is done.

 

 

 

 

See also:

 

pre x()(p. 171)

 

 

 

gdsl_rbtree_map_in x()(p. 172)

 

 

 

4.14.2.17 void gdsl_rbtree_wri e ( onst gdsl_rbtree_t

 

 

 

 

t WRITE

F, FILE

 

 

 

OUTPUT, gdsl writeFILEfun,void

 

 

 

Felemennodes.funtionelementsO(of.eaAdditionnalh nodeoftheofredaUSERred-bla-blaUSERkDATAtreektreeTargumenDATAtoto OUTPUTle)t. ould_beFILE,passedusingto

riteComplexity:the

 

 

 

 

 

WRITE

 

 

 

 

 

Note:

 

 

 

 

 

PPrearameters:WRITEFILETondition:Theust!=redbeNULL-FablavalidThek|Ttreewrite|gdsl)o funrbtreewritetion.t. & WRITE_F != NULL & OUTPUT_-

OUTPUT FILE The le where to write T's elements.

USER DATA User's datas passed to WRITE F.

See gdslalso:_rbtree_writedump()xml()(p. 174)(p. 174)

Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

gdsl Module Do umentation

174.14.2.18 void gdsl_ btree_wri e_xml ( onst gdsl_rbtree_t

 

writeFILEfun,voidt WRITE

F, FILE

 

OUTPUT, gdsl

 

Note:languageelempassWriteComplexitdthetsto.tonWRITEoIfntentOUTPUTWRITEy:elementsO(des ofFa. redFFILEof-!=blatheNULL,.kAdditionnalredtree-blatothenkatreeUSERuseleUSERintoTWRITEtoXMLDATAOUTPUTDA. AF) argumenttoFILE,write T'sintoouldnodesXMLbe

Parameters:reOUTPUTWRITEondition:Theust redbe-aFblavalidFILEThek|Ttreegdslwrite| )Theorbtreefunwritele tionwhere.t. &toOUTPUTwriteT's_FILEelements!=.NULL

USER_DATA User's datas passed to WRITE_F.

See gdslalso:_rbtree_write()dump()(p(p..173)174)

4.14.2.19 void gdsl_rbtree_dump ( onst gdsl_rbtree_t OUTPUT, gdsl writeFILEfun,voidt WRITE F, FILE

Note:Additionnal!=DumpNULL,Complexity:the thenstruinternalUSERusetureO(WRIstruDAoftheTtureAEredargumentFof-blatoredwrik -tblareeouldT'sUSERTknodestreetobeOUTPUTpassedtoelementsDATAa leto. WRITE)toFILEOUTPUT.IfFWRITE.FILEF.

Parameters:re WRITEOUTPUTondition:Theust redbe-aFblavalidFILEThek|Ttreegdslwrite| )Theorbtreefunwritele tionwhere.t. &toOUTPUTwriteT's_FILEelements!=.NULL

Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

4.14 Red-bla k tree manipulation module

175

USER_DATA User's datas passed to WRITE_F.

 

See also:

()(p. 173)

 

gdsl_rbtree_write

 

xml()(p. 174)

 

Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

176

Sort module

gdsl Module Do umentation

 

4.15

 

 

F

 

 

 

4..un15ˆ.1.v1tions.1idmpareSortFunvoidgdslan arraygdsltionfunsortinsortDotpla(gdslCOMPe(gdslumen. elementF)tationelementt

T,t ulong N, onst gdsl_-

Note:elements

beeNpla.userlog(NULLe.-deThefun)n)dfun. tionCOMPCOMPF) TF, isulongused Nto, ompareonst T's

 

SortComplexity:anthearrandrraygdsly mustinTplaO(inompare

 

Pre ondition:

 

 

 

he==TarraynumberFsizeof&TheT!=ofelements(gdslfunelementioelement&poinssortCOMPtotert)TusedF to!= NULLompare&T'sforelementsalli= N: sizeof

Parameters:N(T[i==COMPN ) | |

<

Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen