Space Station 13 - Modules - TypesDefine Details

code/__HELPERS/lists.dm

COMPARE_KEYPassed into BINARY_INSERT to compare keys
COMPARE_VALUEPassed into BINARY_INSERT to compare values
BINARY_INSERT_TGBinary search sorted insert from TG INPUT: Object to be inserted LIST: List to insert object into TYPECONT: The typepath of the contents of the list COMPARE: The object to compare against, usualy the same as INPUT COMPARISON: The variable on the objects to compare COMPTYPE: How should the values be compared? Either COMPARE_KEY or COMPARE_VALUE.
LIST_VALUE_WRAP_LISTSIf value is a list, wrap it in a list so it can be used with list add/remove operations
UNTYPED_LIST_ADDAdd an untyped item to a list, taking care to handle list items by wrapping them in a list to remove the footgun
/proc/pickweightPicks an element based on its weight. L - The input list
/proc/pick_multiple_uniquePicks multiple unique elements from the suplied list. If the given list has a length less than the amount given then it will return a list with an equal amount
LAZYINITLISTInitialize the lazylist
UNSETEMPTYIf the provided list is empty, set it to null
ASSOC_UNSETEMPTYIf the provided key -> list is empty, remove it from the list
LAZYLISTDUPLICATELike LAZYCOPY - copies an input list if the list has entries, If it doesn't the assigned list is nulled
LAZYREMOVERemove an item from the list, set the list to null if empty
LAZYADDAdd an item to the list, if the list is null it will initialize it
LAZYORAdd an item to the list if not already present, if the list is null it will initialize it
LAZYDISTINCTADDAdds I to L, initializing L if necessary, if I is not already in L
LAZYACCESSreturns L[I] if L exists and I is a valid index of L, runtimes if L is not a list
LAZYLENReturns the length of L
LAZYNULLSets a list to null
LAZYCLEARLISTRemoves all elements from the list
LAZYCOPYUse LAZYLISTDUPLICATE instead if you want it to null with no entries
LAZYSETSets the item K to the value V, if the list is null it will initialize it
LAZYSETLENSets the length of a lazylist
LAZYADDASSOCAdds to the item K the value V, if the list is null it will initialize it
LAZYADDASSOCLISTThis is used to add onto lazy assoc list when the value you're adding is a /list/. This one has extra safety over lazyaddassoc because the value could be null (and thus cant be used to += objects)
LAZYREMOVEASSOCRemoves the value V from the item K, if the item K is empty will remove it from the list, if the list is empty will set the list to null
LAZYACCESSASSOCAccesses an associative list, returns null if nothing is found
QDEL_LAZYLISTQdel every item in the list before setting the list to null
LAZYINIf the lazy list is currently initialized find item I in list L
ISINDEXSAFEReturns whether a numerical index is within a given list's bounds. Faster than isnull(LAZYACCESS(L, I)).
LAZYORASSOCLISTPerforms an insertion on the given lazy list with the given key and value. If the value already exists, a new one will not be made.
/proc/make_associativeA proc for turning a list into an associative list.
/proc/compare_listcompare two lists, returns TRUE if they are the same
/proc/avoid_assoc_duplicate_keystakes an input_key, as text, and the list of keys already used, outputting a replacement key in the format of "[input_key] ([number_of_duplicates])" if it finds a duplicate use this for lists of things that might have the same name, like mobs or objects, that you plan on giving to a player as input
/proc/assoc_to_keysTurns an associative list into a flat list of keys
/proc/fill_with_onesGiven a list, return a copy where values without defined weights are given weight 1. For example, fill_with_ones(list(A, B=2, C)) = list(A=1, B=2, C=1) Useful for weighted random choices (loot tables, syllables in languages, etc.)
/proc/pick_weight_recursiveLike pick_weight, but allowing for nested lists.
/proc/lists_equal_unorderedChecks to make sure that the lists have the exact same contents, ignores the order of the contents.

Define Details

ASSOC_UNSETEMPTY

If the provided key -> list is empty, remove it from the list

BINARY_INSERT_TG

Binary search sorted insert from TG INPUT: Object to be inserted LIST: List to insert object into TYPECONT: The typepath of the contents of the list COMPARE: The object to compare against, usualy the same as INPUT COMPARISON: The variable on the objects to compare COMPTYPE: How should the values be compared? Either COMPARE_KEY or COMPARE_VALUE.

COMPARE_KEY

Passed into BINARY_INSERT to compare keys

COMPARE_VALUE

Passed into BINARY_INSERT to compare values

ISINDEXSAFE

Returns whether a numerical index is within a given list's bounds. Faster than isnull(LAZYACCESS(L, I)).

LAZYACCESS

returns L[I] if L exists and I is a valid index of L, runtimes if L is not a list

LAZYACCESSASSOC

Accesses an associative list, returns null if nothing is found

LAZYADD

Add an item to the list, if the list is null it will initialize it

LAZYADDASSOC

Adds to the item K the value V, if the list is null it will initialize it

LAZYADDASSOCLIST

This is used to add onto lazy assoc list when the value you're adding is a /list/. This one has extra safety over lazyaddassoc because the value could be null (and thus cant be used to += objects)

LAZYCLEARLIST

Removes all elements from the list

LAZYCOPY

Use LAZYLISTDUPLICATE instead if you want it to null with no entries

LAZYDISTINCTADD

Adds I to L, initializing L if necessary, if I is not already in L

LAZYIN

If the lazy list is currently initialized find item I in list L

LAZYINITLIST

Initialize the lazylist

LAZYLEN

Returns the length of L

LAZYLISTDUPLICATE

Like LAZYCOPY - copies an input list if the list has entries, If it doesn't the assigned list is nulled

LAZYNULL

Sets a list to null

LAZYOR

Add an item to the list if not already present, if the list is null it will initialize it

LAZYORASSOCLIST

Performs an insertion on the given lazy list with the given key and value. If the value already exists, a new one will not be made.

LAZYREMOVE

Remove an item from the list, set the list to null if empty

LAZYREMOVEASSOC

Removes the value V from the item K, if the item K is empty will remove it from the list, if the list is empty will set the list to null

LAZYSET

Sets the item K to the value V, if the list is null it will initialize it

LAZYSETLEN

Sets the length of a lazylist

LIST_VALUE_WRAP_LISTS

If value is a list, wrap it in a list so it can be used with list add/remove operations

QDEL_LAZYLIST

Qdel every item in the list before setting the list to null

UNSETEMPTY

If the provided list is empty, set it to null

UNTYPED_LIST_ADD

Add an untyped item to a list, taking care to handle list items by wrapping them in a list to remove the footgun