# cp.collect.List

Lists are similar tables which can contain nil items without shortening the length. They also have a few additional methods to assist with managing the size.


# API Overview

Constructors - API calls which return an object, typically one that offers API methods

  • of
  • sized

Methods - API calls which can only be made on an object returned by a constructor

  • size
  • trim

# API Documentation

# Constructors

# of

Signature cp.collect.List.of(...) -> cp.collect.List
Type Constructor
Description Creates a new List with the specified items init.
Parameters
  • ... - The items to put in the list, in order.
Returns
  • The new List instance.
Notes None
Examples None
Source src/extensions/cp/collect/List.lua line 35

# sized

Signature cp.collect.List.sized([size[, defaultValue]]) -> cp.collect.List
Type Constructor
Description Creates a new List with the specified size.
Parameters
  • size - The size of the list. Defaults to 0.
  • defaultValue - If specified, all items in the list will be initialised to the default value.
Returns
  • The new List instance.
Notes None
Examples None
Source src/extensions/cp/collect/List.lua line 9

# Methods

# size

Signature cp.collect.List:size([newSize]) -> number
Type Method
Description Returns and/or sets the current size of the list.
Parameters
  • newSize - if provided, sets the new size of the list. Any values contained above the new size are set to nil.
Returns
  • The size of the list.
Notes None
Examples None
Source src/extensions/cp/collect/List.lua line 88

# trim

Signature cp.collect.List:trim([minSize]) -> cp.collect.List
Type Method
Description Trims the current List to only contain trailing values that are not nil.
Parameters
  • minSize - If provided, the minimum size to trim down to. Defaults to 0.
Returns
  • The same List instance.
Notes None
Examples None
Source src/extensions/cp/collect/List.lua line 66