copy/modify/transfer fullperm
includes "demo test runs" and a lot of documentation.
[[mlist]] a long list that stores multiple lists. It uses the list "mpoint" as pointers.
[[mlplist]] contains [[mlist]] with some functions that make it easier to use: it uses the list "mlp" to point at "mpoint" or to point at empty list [];
[[mlplist]] is only 3 functions
void mlpadd(list) "add entry"
list mlpget(int) "read and keep"
list mlprem(int) "read,remove and switch mode of adding next entry to re-insert"
and they the sub-functions of [[mlist]]: mlistadd(), mlistget(),mlistret()
//list a;integer int;
//mlpadd(a); //stores a sub-list within [[mlist]]
//list a = mlpget(int); //returns the int'th sub-list of [[mlist]]
//list a = mlprem(int); //returns the int'th sub-list of [[mlist]], removes the int'th entry from mlist, and switched "mode" of "mlpadd(list)":
//a=a+["edit"]; //etit a read entry.
//mlpadd(a); //[in switched mode] re-inserts an edited list into position "int" (instead of adding it as a new sub-list-entry)
//mlpadd(a); //stores a sub-list within [[mlist]] [back to default mode] adds sub-list a to [[mlist]]
---
//===start of multilist === (this needs at least //multilist stores multiple sub-lists in one single list and it uses a second list (mpoint) for pointers (where each sub-list starts)
//was developed as part of "lib.f v22" as a way to keep track of all "knot vectors" of multiple b-splines. (yes. lib.f is a NURBS-script)
//this could be much smaller by just using llJson* , but using 3 lists speeds up access and it makes it more accurate for floats!
//v2 first draft adding, adding reading removing works nicely
//v3 mlp static indexing functions adding and reading works nicely.
//v3 adds another list (mlp) to keep pointers static and to allow to point at empty lists.
//v4 testing mlp functions
list mpoint;//a list if integer-pointers that point on positions of mpoint. mlist stores llGetListLength(mpoint) sub-lists.
list mlist; //a list that contains multiple lists, (start and end) position oper list are pointed at by "mpoint"
//mpont and mlist can not store empty lists as sub-lists.
//to change a stored list it must be "read and removed" and then be "added" again. and that changes the index in mpoint.
//i did not make "add a sub-list" to llListInsertList, because that would be much slower.
//instead i made 2 lists of pointers "mpoint" (where index positions may vary).
//and "mlp" (where the same index-position will get you the same sub-list. (see below) [this only slows down if you remove low values)].
list mlp;//mlp is optional, mlp-pointer-values are on the same positions and point at the corresponding sub-lists, after moving mpointer position.
//mlp values can also be ==0 to point at an empty list [];
//mlp values never get removed, they just become ==0. mlp just exists to allow for stable indexing while...
//mpoint changes its index/value positions when a sub-list gets removed, edited and added at the end.
//mlp stores value "0" in any position to indicate that this position of mlp stores an empty list.
//mlp stores value n>0 in any position to indicate that it stores whatever position "n-1" of npoint points at.
//each value of mlp points at one position of mpoint (or at "0". mlp values are +1 higher than mpoint positions, because it needs a "0"==null_pointer
//mlp dioes not go too well with "out of range" values and not at all with negative values. supporting that would make it slower. no need to!
//multiple mlp-entries may directly be edited to point at the same mpoint-value, returning the very same sub-list like a true pointer...
//BUT removing an entry will set ALL pointers that point at that entry to become NULL_POINTERS and only 1 will point at a changed/stored value!!!
//(todo, maybe [integer mrem;] needs to be a list, but i see no need to support "true pointers" though.
//if an mpoint-entry gets removed, the corresponding mlp value gets set to 0, but its mlp-value is remembered in [integer mrem;]
//if the mpoint-entry gets changed and stored at the end, the same mlp,entry points at it again (insead of pointing at 0).
//the positions in mlp are static and pointing at a dymanic list of pointers (mpoint).
//using 2 lists mpoint and mlp like this, instead of a single strided list, has some speed and flexibility advantages.
//using only a single pointing list makes it less flexible and slower on inserting a sub-list.
//mlp is not needed if you are not storing empty lists and if you can keep track of changing pointers in other ways. (or just dont want to)
//otherwise mlp will keep track of moving pointers and empty lists for you.
//if (your sub-lists can be unsorted and change orders in any way within mlist) "mlp" is absolutely not needed.
//for "empty list" you can also define one alias, like ["empty"] so you wont need mlp just to store empty lists.
- stores as many lists of any length in a single list
- uses 1 or 2 lists as pointers (1 for unsorted, 2 for static pointers)
- does not use json functions, making it faster
- only uses 3 functions, fast small and flexible.
- compact: 54,880 k free memory