InPlace.LinkedList
(inplace v0.7.1)
Copy Markdown
Singly linked list The data entries are stored as integers. They will be interpreted (as references) by the calling application. Note: indices are 1-based. Options:
mode:: :singly_linked | :doubly_linkedcircular:: boolean() optional,falseby default;deletion:: :reclaim | :hide | :rewind Handles if the element pointer could be restored later (see delete_pointer/2), and how to restore it::reclaim(default) - element can not be restored, the pointer will be put back to theallocationpool;:hide- element can be restored by re-linking with it's formerleftandrightneighbors; The element stays in the list, but can not be reached except by directly addressed by it's pointer. The element can be put back to it's position by reconnecting previously prior and next elements back to that element (see hide/2 and restore/2);:rewind- if specified, the special stack of removed element pointers is maintained. The effect of removal will be the same as for :hide, except that The elements can be restored in the reverse order of their removal by usingrewind/1.:mapper_fun# maps data entries to application data optional, &Function.identity/1 by default
Summary
Functions
This will create a circuit out of the list of pointers.
Delete element at position (1-based)
Get element at position (1-based)
Insert data element at position (1-based)
Functions
This will create a circuit out of the list of pointers.
!!!!! Hazard warning !!!!! If you want to avoid infinite loops while iterating over the list that contains circuits, make sure that you start the iteration within the circuit (using :start option fir iterate/2).
For instance
import InPlace.LinkedList
ll = new(Enum.to_list(1..10))
circuit(ll, [2, 4, 6])
iterate, start: 1, action: fn p -> IO.inspect(p) endwill loop indefinitely, as the iteration will be trapped in 2 -> 4 -> 6 circuit
once entering it from 1 pointer.
Delete element at position (1-based)
Get element at position (1-based)
Insert data element at position (1-based)