Module Core_kernel__Doubly_linked_intf
Doubly-linked lists.
Compared to other doubly-linked lists, in this one:
1. Calls to modification functions (insert*
, move*
, ...) detect if the list is being iterated over (iter
, fold
, ...), and if so raise an exception. For example, a use like the following would raise:
iter t ~f:(fun _ -> ... remove t e ...)
2. There is a designated "front" and "back" of each list, rather than viewing each element as an equal in a ring.
3. Elements know which list they're in. Each operation that takes an Elt.t
also takes a t
, first checks that the Elt
belongs to the t
, and if not, raises.
4. Related to (3), lists cannot be split, though a sort of splicing is available as transfer
. In other words, no operation will cause one list to become two. This makes this module unsuitable for maintaining the faces of a planar graph under edge insertion and deletion, for example.
5. Another property permitted by (3) and (4) is that length
is O(1).
module type S = sig ... end
module type Doubly_linked = sig ... end