module Doubly_linked: Doubly_linkedModification functions include: insert_*, remove*, transfer Iteration functions include: exists, fold*, for_all, find
Calls to modification functions detect if the list is being iterated over, and if so raise an exception rather than modify the list. For example, a use like the following would raise.
iter t ~f:(fun _ -> ... remove t e ...)
module Elt:sig..end
type 'a t
include Container.S1
val invariant : 'a t -> unitval create : unit -> 'a tval of_list : 'a list -> 'a tof_list l returns a doubly-linked list t with the same elements as l and in the
same order (i.e. the first element of l is the first element of t). It is always
the case that l = to_list (of_list l).val equal : 'a t -> 'a t -> boolval is_first : 'a t -> 'a Elt.t -> boolval is_last : 'a t -> 'a Elt.t -> boolval first_elt : 'a t -> 'a Elt.t optionval last_elt : 'a t -> 'a Elt.t optionval first : 'a t -> 'a optionval last : 'a t -> 'a optionval next : 'a t -> 'a Elt.t -> 'a Elt.t optionval prev : 'a t -> 'a Elt.t -> 'a Elt.t optionval insert_before : 'a t -> 'a Elt.t -> 'a -> 'a Elt.tinsert_before t e
a or insert_after t e a if e is not an element in t, and will break
invariants.val insert_after : 'a t -> 'a Elt.t -> 'a -> 'a Elt.tval insert_first : 'a t -> 'a -> 'a Elt.tval insert_last : 'a t -> 'a -> 'a Elt.tval remove : 'a t -> 'a Elt.t -> unitremove t e when e is
not in t, and will break invariant.val remove_first : 'a t -> 'a optionval remove_last : 'a t -> 'a optionval fold_elt : 'a t -> init:'b -> f:('b -> 'a Elt.t -> 'b) -> 'bfold_elt t ~init ~f is the same as fold, except f is called with the 'a Elt.t's
from the list instead of the contained 'a values.
Note that like other iteration functions, it is an error to mutate t inside the
fold. If you'd like to call remove on any of the 'a Elt.t's, accumulate them here
and do so after fold_elt returns.
val fold_right : 'a t -> init:'b -> f:('a -> 'b -> 'b) -> 'bval find_elt : 'a t -> f:('a -> bool) -> 'a Elt.t optionfind_elt t ~f finds the first element in t that satisfies f, by testing each of
element of t in turn until f succeeds.val clear : 'a t -> unitclear t removes all elements from the list in constant time.val copy : 'a t -> 'a tcopy t returns a copy of t.val transfer : src:'a t -> dst:'a t -> unittransfer ~src ~dst has the same behavior as
iter src ~f:(insert_last dst); clear src
except that it runs in constant time.
If s = to_list src and d = to_list dst, then after transfer ~src ~dst:
to_list src = []
to_list dst = d @ s
val filter_inplace : 'a t -> f:('a -> bool) -> unitfilter_inplace t ~f removes all elements of t that don't satisfy f.val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a tval sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.t