dmd.backend.dlist
Interface to the C linked list type.
Discussion
List is a complete package of functions to deal with singly linked lists of pointers or integers.
Features:
- Uses mem package.
- Has loop-back tests.
- Each item in the list can have multiple predecessors, enabling different lists to 'share' a common tail.
License
Source:
backend/dlist
.d
-
Declaration
nothrow @nogc @safe list_t
list_link
(list_tlist
);Create link to existing
list
, that is, share thelist
with somebody else.Return Value
pointer to that
list
entry. -
Declaration
nothrow @nogc @safe list_t
list_next
(list_tlist
);Return Value
pointer to next entry in
list
. -
Declaration
nothrow @nogc @trusted inout(void)*
list_ptr
(inout list_tlist
);Return Value
ptr from
list
entry. -
Declaration
nothrow @nogc @safe int
list_data
(list_tlist
);Return Value
integer item from
list
entry. -
Declaration
nothrow @nogc @safe void
list_appenddata
(list_t*plist
, intd
);Append integer item to list.
-
Declaration
nothrow @nogc @safe void
list_prependdata
(list_t*plist
, intd
);Prepend integer item to list.
-
Declaration
nothrow @nogc @trusted void
list_init
();Initialize list package.
Output: list_inited = 1
-
Declaration
nothrow @nogc @trusted void
list_term
();Terminate list package.
Output: list_inited = 0
-
Declaration
nothrow @nogc @trusted void
list_free
(list_t*plist
, list_free_fpfreeptr
);Free list.
Parameters
list_t*
plist
Pointer to list to free
list_free_fp
freeptr
Pointer to freeing function for the data pointer (use FPNULL if none)
Output: *
plist
isnull
-
Declaration
nothrow @nogc @trusted void*
list_subtract
(list_t*plist
, void*ptr
);Remove
ptr
from the list pointed to by *plist
.Output: *
plist
is updated to be the start of the new listReturn Value
null
if *plist
isnull
otherwiseptr
-
Declaration
nothrow @nogc @safe void*
list_pop
(list_t*plist
);Remove first element in list pointed to by *
plist
.Return Value
First element,
null
if *plist
isnull
-
Declaration
nothrow @nogc @trusted list_t
list_append
(list_t*plist
, void*ptr
);Append
ptr
to *plist
.Return Value
pointer to list item created.
null
if out of memory -
Declaration
nothrow @nogc @trusted list_t
list_prepend
(list_t*plist
, void*ptr
);Prepend
ptr
to *plist
.Return Value
pointer to list item created (which is also the start of the list).
null
if out of memory -
Declaration
nothrow @nogc @safe int
list_nitems
(list_tlist
);Count up and return number of items in
list
.Return Value
of entries in
list
-
Declaration
nothrow @nogc @safe list_t
list_nth
(list_tlist
, intn
);Return Value
nth
list
entry inlist
. -
Declaration
nothrow @nogc @safe list_t
list_last
(list_tlist
);Return Value
last
list
entry inlist
. -
Declaration
nothrow @nogc @safe list_t
list_prev
(list_tstart
, list_tlist
);Return Value
pointer to previous item in
list
. -
Declaration
nothrow @nogc @trusted list_t
list_copy
(list_tlist
);Copy a
list
and return it. -
Declaration
nothrow @nogc @safe int
list_equal
(list_tlist1
, list_tlist2
);Compare two lists.
Return Value
If they have the same ptrs, return 1 else 0.
-
Declaration
nothrow @nogc @trusted int
list_cmp
(list_tlist1
, list_tlist2
, int function(void*, void*) nothrow @nogcfp
);Compare two lists using the comparison function
fp
. The comparison function is the same as used for qsort().Return Value
If they compare equal, return 0 else value returned by
fp
. -
Declaration
nothrow @nogc @trusted list_t
list_inlist
(list_tlist
, void*ptr
);Search for
ptr
inlist
.Return Value
If found, return
list
entry that it is, elsenull
. -
Declaration
nothrow @nogc @safe list_t
list_cat
(list_t*pl1
, list_tl2
);Concatenate two lists (
l2
appended to l1).Output: *
pl1
updated to be start of concatenated list.Return Value
*
pl1
-
Declaration
nothrow @nogc @trusted void
list_apply
(list_t*plist
, void function(void*) nothrow @nogcfp
);Apply a function
fp
to each member of a list. -
Declaration
nothrow @nogc @safe list_t
list_reverse
(list_tl
);Reverse a list in place.
-
Declaration
nothrow @nogc @trusted void
list_copyinto
(list_tl
, void*pa
);Copy list of pointers into an array of pointers.
-
Declaration
nothrow @nogc @trusted list_t
list_insert
(list_t*pl
, void*ptr
, intn
);Insert item into list at nth position.
-
Declaration
struct
ListRange
;Range for Lists.
-
Declaration
nothrow @trusted list_t
list_build
(void*p
, ...);Build a list out of the
null
-terminated argument list.Return Value
generated list