Skip to content

creepersaur/QuickList

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quicklist_logo|442x154

GitHub|107x32 Library|107x32 Wally|107x32

QuickList is a Lua (class) library for managing arrays efficiently. It provides a set of functions for manipulating arrays in a concise and expressive manner. This was made by creepersaur. Go and subscribe to him on Youtube.

Installation

Download the QuickList.lua from the source code. Or use releases if an older version is there. Just require(path) to the QuickList module. Then use the returned value to make lists. Name the variable anything, but it's best to name it something short (such as ql or underscore)

If you use Wally for managing packages, you can install it using the following line:

QuickList = "creepersaur/quicklist@^1.0"

For anyone willing to use this on Roblox (as intended), copy the contents of QuickList.lua and paste them into a ModuleScript. Then require(path_to_module).

Example

local ql = require('QuickList')
local myTable: ql.QuickList = ql {
    'Hello',
    "World",
    123
}

print(myTable)

Output:

> {Hello, World}

QuickList Class

Note

require(path_to_quicklist)

Returns the Quicklist export type and new() in the same require.

local ql = require(path)
ql.Quicklist -- this is the type
ql() or ql{} -- create a new quicklist

Note

ql.new(_table) Creates a new 'QuickList' array. Use ql{values} to make it easier to create a QuickList.

Parameters:

  • _table: A QuickList or table (optional).

Returns:

  • QuickList: A new QuickList array.

Note

self.copy() Creates a shallow copy of the table.

Returns:

  • QuickList: A copy of the QuickList.

Note

self> .insert(pos, value) Inserts a value at a specific index. Anything in front will be pushed forward.

Parameters:

  • pos: Index to insert the value.
  • value: Value to insert.

Returns:

  • QuickList: Modified QuickList.

Note

self.append(value) Inserts a value at the end of the table.

Parameters:

  • value: Value to append.

Returns:

  • QuickList: Modified QuickList.

Note

self.join(sep) Joins the table using a separator. (Optional)

Parameters:

  • sep: Separator (optional).

Returns:

  • string: Joined string.

Note

self.split(index) Splits the table into two tables using an index.

Parameters:

  • index: Index to split the table.

Returns:

  • QuickList: Two tables resulting from the split.

Note

self.sort(comp) Returns > a sorted copy of the table. Use the parameter "descending" to sort descending or provide a custom comparison function.

Parameters:

  • comp: Comparison function or "descending" (optional).

Returns:

  • QuickList: Sorted > copy of the table.

Note

self.forEach(func) Loops through the list. Callback (v:Value).

Parameters:

  • func: Callback function.

Returns:

  • QuickList: Modified QuickList> .

Note

self.enumerate(func) Loops through the list. Callback (i:Index, v:Value).

Parameters:

  • func: Callback function.

Returns:

  • QuickList: Modified QuickList.

Note

self.merge(tab) Merges a copy of this table with another. Appends the values to the end.

Parameters:

  • tab: Another QuickList or table.

Returns:

  • > QuickList: Merged QuickList.

Note

self.rep(value, times) Adds a value multiple times to the en> d.

Parameters:

  • value: Value to repeat.
  • times: Number of times to repeat (optional, default is 1).

Returns:

  • QuickList: Modified QuickList.

Note

self.remove(pos) Removes a value at a specific positio> n.

Parameters:

  • pos: Position to remove.

Returns:

  • > QuickList: Modified QuickList.

Note

self.pop(pos) Removes the value at a specific position and returns i> t.

Parameters:

  • pos: Position to pop.

Returns:

  • Value: Removed value.

Note

self.move(pos1, pos2) Moves a value from one position/index to anothe> r.

Parameters:

  • pos1: Source position.
  • pos2: Destination position.

Returns:

  • QuickList: Modified QuickList.

Note

self.reverse() Returns a reversed copy of the tabl> e.

Returns:

  • QuickList> : Reversed copy of the table.

Note

self.string(str, sep) Splits a string into a QuickLis> t.

Parameters:

  • str: Input string.
  • sep: Separator (optional).

Returns:

  • QuickList: Resulting QuickList.

Note

self.> find(value) Checks if a value exists in the table. Returns the index if found, otherwise returns > nil.

Parameters:

  • value: Value to find.

Returns:

  • Index or > nil.

Note

self.occurrences(value) Gets the number of times a value shows up in the tabl> e.

Parameters:

  • value: Value to count.

Returns:

  • number.

Note

self.unique() Returns a copy of the table with unique value> s.

Returns:

  • QuickList: Modified QuickList.

Note

self.get_dictionary() Returns a dictionary where values are indexed by [1], [2], et> c.

Returns:

  • table: Dictionary.

Note

self.shuffle() Returns a shuffled copy of the tabl> e.

Returns:

  • QuickList: Shuffled copy of the table.

Note

self.random() Gets a pseudo-random value from the tabl> e.

Returns:

  • Value: Random value.

Note

self.flatten() Returns a new QuickList by flattening nested table> s.

Returns:

  • QuickList: Flattened QuickList.

Note

self.average() Gets the average of all number values inside the tabl> e.

Returns:

  • number: Average value> .

Note

self.startsWith(tab) Checks if the QuickList starts with a given sequence (table) of element> s.

Parameters:

  • tab: Sequence to check.

Returns:

  • boolean: True if the QuickList starts with the sequence, otherwise false> .

Note

self.endsWith(tab) Checks if the QuickList ends with a given sequence (table) of element> s.

Parameters:

  • tab: Sequence to check.

Returns:

  • boolean: True if the QuickList ends with the sequence, otherwise false.

Note

self.checkql(tab)>

**Returns: **

  • boolean: True if the table provided is a QuickList

Note

self.sum() **Returns: **

  • number: Adds all the number values in the list and gives the sum.

Note

self.retain()> Deletes the item inside the QuickList if the function returns false for that item.

parameters

  • func(i: number, v: any)

About

A better lua list class.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages