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

4.10 Doubly-linked list manipulation module

107

ˆ

element_t gdsl_list_map_ba kward ( onst gdsl_list_t L,

ˆgdslvoidWRITEParsegdslmapF,listlistFILEfunfromwritetailMAPto(headonstF,. voidgdsl USERlist t DATA)L, gdsl_write_fun _t

ˆvoidfun ritegdslWRITEall thelistelemenF,OUTPUTFILEs ofxmla list (FILE,toonsta levoid.gdsl_USERlist_tDATA)L, gdsl_write_-

ˆWRITEvoid gdsltheF,listFILEontentdumpof a list( onsttoOUTPUTa gdslle into_listXMLFILE,.t voidL,gdslUSERwriteDATA)fun _t

ˆgdslL) DumpCrDestrgdslatelistoyahealistnewinternalursorlistursorOUTPUTursorstru.gdsl.turfreee oflist(FILE,gdsla list_ursortovoidlista leUSER.allourorgdsl _list(DATA)onstC) gdsl_list_t

 

 

gdsl_

_

move_ _head (

_

_ ursor_t C)

 

void gdsl_

_

move to_tail (gdsl_list_ ursor_t C)

 

 

 

 

head of its list.

 

 

ˆ

Put a ursor on the tail of its list.

 

 

gdsl

 

 

t gdsl_list_ ursor_move_to_ alue (gdsl_list_-

 

MovePlaPlagdslelemenelemenursoraat C,listursorursorgdslt C,ononetursorulonggdslastepompareelementartiforwardstepPOS)listulargivenelementfunforwardofursorbyitsitslist.t COMPposition.move(gdsl. toF,listvoidpositionursorVALUE)(tgdslC) _-

ˆ voidlistgdslursor

 

 

 

 

 

 

gdsl_list_

_step ba kward gdsl_list

ursor_t C)

ˆ bool gdsl

list

ba kward of its list.

gdsl_list_ ursor_t

ursor is on head ( onst

 

C) Che k if a ursor is on the head of its list.

 

 

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

 

 

108

 

 

 

 

 

 

 

 

 

 

gdsl Module Do umentation

ˆ bool

gdsl_list_ ursor_is_on tail ( onst gdsl_list_ ursor_t

 

C)

 

 

 

 

is on the tail of its list.

 

 

 

 

 

 

 

 

 

 

 

su ( onst gdsl_list_ ursor_t C)

 

bool gdsl_list

 

 

 

su essor.

 

gdsl_list_ ursor_t C)

 

 

ursor_has

pred

 

ˆ

 

Che k if a ursor has a

prede essor.

 

 

 

void

gdsl list

 

ursor

set

 

onten( onst(gdsl_list_ ursor_t C,

ˆ gdsl_elemen

 

t

E)

 

 

 

 

 

 

( onst gdsl_-

 

gdsl list_ ursor_get_ ontent

 

 

Set th

 

of the ursor.

 

 

 

 

 

 

 

Getursorthe

 

of a ursor.

 

 

_insert_after

(gdsl_list_-

ˆ gdsl

elemenontent

 

gdsl

list_

 

 

list

 

C)

 

 

 

 

 

 

 

 

ˆ gdslursorursorInsertelementtta C,C,newvoidvoidelementelementVALUE)gdslafterlista _ursorursor. _insert_before

(gdsl_list_-

ˆˆ gdslC)gdslursorRemoveInsertelemenelementa C)newtheelementgdslVALUE)gdslunderbeforelistlistaa ursor.. __removeremove(gdslafterlist(gdslursorlist__t-

Remove the

 

after a ursor.

 

 

ˆ gdsl elemen _ gdsl list

ursor_remove_before (gdsl_list_-

ursor

C)

 

 

 

 

 

 

 

ursorlist

C)

 

before a ursor.

 

 

Remove the

 

(gdsl_list_-

ˆ gdsl

ursor_

gdsl

 

list_ ursor_delete

ursor

C)

 

 

 

 

 

 

 

Delete the element under a ursor.

 

 

ˆ gdsl

ursor_ gdsl_list

.

ursor_delete_after (gdsl_list_-

Delete the element after a

 

Jun 22 11:15:30 2006 for gdsl by Doxygen

 

 

 

Generated onursorTh

 

4.10 Doubly-linked list

module

 

109

ˆ gdsl

list

ursor_manipulationgdsl list_ ursor_delete_before

(gdsl_-

 

list ursor_ C)

 

 

 

 

 

Delete the element before the ursor of a list.

 

 

 

. .1

T

Do umentation

 

 

 

 

4..1010nitionby..11ype..doublythe21 isatfuntypedefypedefvoluntaryline-linktions51 struofstrulistopaquethisleypettgdslmodule..gdslgdslVariableslist..hlistlist. ofgdslursorthis kindlist ould'ntt

be dire tly used,

4butDeThisGDSL

 

 

 

 

 

 

 

 

 

onoflistopaquethisDoleursorgdslmoduleument. Variablestypelist...ha. tionof this

kindgdslould'ntlist be ursordire tlytused,

4butDeThisGDSL.10nitionby.ype2doublytheisatFfunvoluntaryli-linkedtionse59

 

defaultandfunAlloCreate. tionfree.ate2.a1ones:pointerselementsanewnewFREEgdsllistlist.ALLOCalloinstdataFthe) tstrulistfungdslF. andtureTheselistFREEALLOCwhipointerslloh nameF (ouldFonstould,isgdslsetbebeharusedtosetfreea toNAMEpyrespeNULLfunof NAMEtively,,tto use.alloTthe

ˆ the default ALLOC F simply returns its argumen Note: FREE F does nothing

Complexity: O( 1 )

Pre nothingondition:

arameters:NAME The name of the new list to reate

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

110

ALLOC

 

F Fun tion to allo

gdsl Module Do umentation

 

 

t when inserting it in t

 

 

FREE F Fun tion to free elemement when removing it from the list

Returns:

 

 

 

 

llo ated list

ase of su ess.

 

the newly

 

 

NULL in

ase of insu ient memory.

 

 

See also:

 

 

 

 

free()(p. 1

 

 

 

 

gdsl_list_ ush()(p. 110)

 

 

4.10.2.2

 

 

void gdsl_list_free (gdsl_list_t L)

Destroy

 

list.

 

 

 

 

 

Flush and destroy the list L. All the elements of L are freed using L's FREE_F

fun tion passed to gdsl list

allo ()(p. 109).

Note:

 

listlistbey:atoallovalidO(ushdestroyL()gdsl(p) .109)10list_t

 

 

 

LComplexitalso:ondition:Theust

 

 

 

 

 

gdsl

 

 

 

 

 

 

 

 

 

Parameters:re

 

| |

 

 

 

See

 

 

 

 

 

 

 

 

 

4.10.2.3

 

 

void gdsl_list_ ush (gdsl_list_t L)

Flush a

 

 

.

he e ements of the list L by alling L's FREE F fun tion passed

Destroy lista

 

to gdsl

list

allo ()(p. 109). L is not deallo ated itself and L's name is not

m di ed.

 

 

 

 

 

 

 

 

 

Note:

 

 

 

 

 

 

 

 

 

 

LComplexity:also:ondition:Theustlistbe atofree()allovalidO(ushL()gdsl(p(p). 1. 10list9)_t

 

 

 

gdsl

 

 

 

 

 

 

 

 

 

Parameters:re

 

| |

 

 

 

See

 

 

 

 

 

 

 

 

 

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

Doubly-linked list manipulation module

111

4.re10LComplexitthe.ondition:2.4nameustbeonstofy:a avalidO(listhar1.gdsl)gdsllistlistt _get_name ( onst gdsl_list_t L)

 

Note:Get

 

 

 

 

 

ost ondi

 

:

 

 

Parameters:

 

 

 

The

ur ed string MUST NOT be freed.

 

 

L

The list to get the name from

 

 

Returns:

 

 

 

 

the name of the list L.

 

 

See also:

 

 

 

 

gdsl_list_set_name()(p. 113)

 

 

4.10.2.5

ulong gdsl_list_get_size ( onst gdsl_list_t L)

 

Get the size of a list.

 

 

Note:

 

 

 

 

 

Complexity: O( 1 )

 

 

re ondition:

 

 

 

 

ust be a valid gdsl_list_t

 

 

Parameters:

 

 

 

L

The list to get the size from

 

 

 

 

 

emptlist Ly (noted( onst Lgdsl). _list_t L)

 

Note:Returns:Che4.10Complexitthe.k2.if6aumberlistboolisy:ofemptygdslO(elements1).list_ofisthe

| |

 

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

 

L

ust be a valid gdsl list_t

 

 

112

 

 

 

 

 

 

gdsl Module Do umentation

 

Parameters:

 

 

 

 

 

 

 

 

L The list to he k

 

 

 

Returns:

 

L is

y.

 

 

 

 

 

TRUE if

 

 

 

 

 

FALSE ifthelist

L is not empty.

 

 

 

4.10.2.7 gdsl_elemenemptgdsl_list_get_head ( onst gdsl_list_t

 

 

 

 

 

L)

 

 

 

 

 

 

Get the head of a list.

 

 

 

 

Note:

 

 

 

 

 

 

 

P

re ondition:y: O( 1 )

 

 

 

 

Complexitust be a valid gdsl_list_t

 

 

Returarameters:

 

 

 

 

 

 

 

 

L

The list to get the head from

 

 

 

 

 

the element at

 

head position if L is not empty. The returned element

 

 

 

NULL if he

L's is empty.

 

 

 

 

 

is not removed from L.

(p. 112)

 

 

 

 

 

gdsl_list_glist

 

 

 

See also:

 

 

 

 

 

 

 

4.10.2.8 gdsl_elementail()_t gdsl_list_get_tail ( onst gdsl_list_t L)

 

Get the tail of a list.

 

 

 

 

Note:

 

 

 

 

 

 

 

 

 

 

Complexity: O( 1 )

 

 

 

 

 

re ondition:

 

 

 

 

 

Parameters:ust be a valid gdsl_list_t

 

 

 

 

 

L

The list to get the tail from

 

 

 

 

 

the element at L's tail position if L is not empty. The returned element is

Returns:

 

 

 

 

 

 

 

 

 

not removed from L.

 

 

 

 

 

 

NULL if L is

mpty.

 

 

 

See also:

 

 

 

 

 

 

 

 

 

gdsl_list_get_head()(p. 112)

 

 

 

 

 

 

 

 

 

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

 

 

Doubly-linked

manipulation module

113

 

4.10.2.9

gdsl_ _listgdsl_list_set_name (gdsl_list_t L, onst

 

 

LComplexitondition:nameustthebeharpreviousofy:aavalidO(listNEW1.namegdsl)_NAMEoflistthet list) L to a opy of NEW_NAME.

 

PNote:ChangesSetrethe

 

 

 

 

 

 

arameters:

 

 

name

 

 

The list to hange

 

 

 

NEW NAME Thethen w name of L

 

Returns:

 

 

 

 

 

 

the modi ed list in ase of su ess.

 

 

NULL in ase of failure.

 

 

See also:

 

 

 

 

 

 

gdsl_list_get_name()(p. 111)

 

 

4.10.2.10 gdsl_element_t gdsl_list_insert_head (gdsl_list_t L,

Note:new

 

 

 

llingistpassed.headerL'stoALLOCpositiongdsl listofF_thefunallolisttion()L(p.on.109)VALUE.The.

 

AInsertLLOClloComplexiteleateanenaelemenFnewisvoidEthey:iselemenO(thenatfunVALUEthe1tion)insertedheadEpointerby)ofatathe

 

 

re ondition:

 

 

 

 

Parameters:ust be a valid gdsl_list_t

 

 

L The list to insert into

 

 

 

VALUE The value used to make the new element to insert into L

 

Returns:

 

lement E in ase of su ess.

 

 

the

 

 

 

NULLinsertedase of failure.

 

 

See also:

insert_tail()(p. 114)

 

 

head()(p. 114)

 

tail()(p. 115)

gdsl_list_remove()(p. 115)

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

114 gdsl Module Do umentation

.10.2.11 gdsl_element_t gdsl_list_insert_tail (gdsl_list_t L,

AInsertLLOClloComplexitelemenateanaelemenFnewisvoidEthey:iselemenO(thenatfunVALUEthe1tion)insertedtailEpoinby)f aatterlistallingthepassed.footerL'stoALLOCpositiongdsl listofF thefunallistotion()L.(pon.109)VALUE.The.

Note:new

 

 

 

 

 

 

 

re ondition:

 

 

 

 

 

 

ust be a valid gdsl_list_t

 

 

Parameters:

 

 

 

 

 

L

The list to insert into

 

 

VALUE The value used to make the new element to insert into L

Returns:

 

lement E in ase of su ess.

the

 

 

NULLinsertedase of failure.

 

 

See also:

 

 

head()t il()(p(p. 115). 114)

 

insert_he

3)

 

gdsl_list_remove()(p. 115)

 

 

4.10.2.12 gdsl_element_t gdsl_list_remove_head (gdsl_list_t L)

 

 

head of a list.

 

 

 

Remove the element at the head of the list L.

Note:

 

 

 

 

 

 

 

Complexity: O( 1 )

 

 

 

re ondition:

 

 

 

 

 

 

ust be a valid gdsl_list_t

 

 

Parameters:

 

 

 

 

 

L

The list to remov the head from

 

Returns:

 

Generated on Thsu Juness 22 11:15:30 2006 for gdsl by Doxygen

 

lemen in ase of

 

.

the removed

 

NULL in

ase of L is empty.

 

 

 

4.10 D ubly-linked list manipulation module

115

 

See also:

 

 

 

 

 

 

 

 

 

 

insert_

he d

 

 

3)

 

 

 

 

il()p(p. 114). 115)

 

 

gdsl_list_removetail()(p. 115)

 

 

 

4.10.2.13 gdsl_element_t gdsl_list_remove_tail (gdsl_list_t L)

 

 

tail of a list.

 

 

 

 

 

 

Remove the element at the tail of the list L.

 

Note:

 

 

 

 

 

 

 

 

 

Complexity: O( 1 )

 

 

 

 

 

 

re ondition:

 

 

 

 

 

 

 

 

ust be a valid gdsl_list_t

 

 

 

Parameters:

 

 

 

 

 

 

 

 

L

The list to remove the tail from

 

Returns:

 

lement in ase of su ess.

 

 

the removed

 

 

NULL in

ase of L is empty.

 

 

 

See also:

insert_

head()(p. 113)

 

 

 

 

 

(p. 114)

 

 

gdsl_list_removetail()head()(p. 115

 

 

4.10.2.14

 

element_

 

(p. 114)

 

 

gdsl_list_remove (gd l_list_t L,

 

 

 

gdslity:listularO(removedLompareforelementhefromrstfromfunelemenLaandlistthen.COMPE equalreturnedtoFVALUE, . onstbyvoidusing VALUECOMP F) .

Note:IfSearRemoveEComplexitishfound,intoapartithe

 

 

 

 

 

 

PGeneratedarameters:reLondition:TheustonlistbeThuatovalidJunremove|22Lgdsl| 11:15:30/ the2)listelement2006t &forCOMPfromgdsl byFDoxygen!= NULL

116

 

 

 

 

 

 

 

 

gdsl Module Do umentation

 

COMP_F The omparison fun tion used to nd the

to remove

 

 

VALUE The value used to ompare the element to removelemenwith

Returns:

 

 

 

 

 

 

 

 

 

 

the founded lement E if it was found.

 

 

 

 

NULL in ase the sear hed element E was not found.

 

 

See also:

 

insert_

he

. 113)

 

 

 

 

 

 

 

 

(p. 114)

 

 

 

 

 

 

 

 

 

 

head()(p. 114)

 

 

 

 

gdsl_list_removetail()(p. 115)

 

 

 

4.10.2.15 gdsl_list_t gdsl_list_delete_head (gdsl_list_t L)

D lete

 

 

of a list.

 

 

 

 

 

 

Removthetheheadader elemen from the list L and deallo ates it using the FREE_F

fun tion passed to gdsl

 

 

list

allo ()(p. 109).

 

 

Note:

 

 

 

 

 

 

 

 

 

 

 

Complexity: O( 1 )

 

 

 

 

 

 

 

re ondition:

 

 

 

 

 

 

 

 

 

 

ust be a valid gdsl_list_t

 

 

 

Parameters:

 

 

 

 

 

 

 

 

 

L

The list to destroy the head from

 

 

 

Returns:

 

 

 

 

 

 

 

 

 

 

the modi ed list L in ase of su ess.

 

 

 

 

NULL if L is empty.

 

 

 

 

 

 

See also:

 

 

(p. 109)

 

 

 

 

 

sl_list_

 

 

 

 

gdsl_list_destroyallo ()tail()

 

 

 

 

4.10.2.16

gdsl

 

t gdsl_list_delete_tail (gdsl_list_t L)

D lete

 

tail of a list.

 

 

 

 

 

 

 

Removthethe footer elemen from the list L and deallo ates it using the FREE_F

fun tion passed to gdsl

 

 

list

allo ()(p. 109).

 

 

Note:

 

 

 

 

 

 

 

 

 

 

 

Complexity: O( 1 )

 

 

 

 

 

 

 

 

 

 

 

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