Emojicode Documentation 1.0 beta 2

Value Type 🍨🐚ElementβšͺοΈπŸ†

List, an ordered mutable collection.

🍨 provides random access, appending and removing from the last element in O(1).

🍨 is a value type. This means that copies of 🍨 are independent:

🍿 πŸ”€redπŸ”€ πŸ”€greenπŸ”€ πŸ”€blueπŸ”€ πŸ† ➑️ colors
colors ➑️ πŸ–πŸ†•otherColors
🐻 otherColors πŸ”€pinkπŸ”€β—οΈ

In the above example the dictionary in colors will still contain only three strings as only otherColors was modified.

To learn more about collection literals see the Language Reference.

Initializers

πŸ†•

πŸ–  πŸ†• 

Creates an empty list.

πŸ†•β–ΆοΈπŸ΄

πŸ–  πŸ†•β–ΆοΈπŸ΄  capacity πŸ”’ 

Creates an empty list with the given initial capacity.

Note that this initializer does not place any values in the list. This initializer can be used for better performance if the number of values that will be added is known in advance.

πŸ†•β–ΆοΈπŸͺ

☣️ πŸ–  πŸ†•β–ΆοΈπŸͺ  values 🧠  count πŸ”’ 

πŸ†•

πŸ–  πŸ†• 🎍πŸ₯‘ repeatedValue Element  count πŸ”’ 

Creates an containing the specified number of a single, repeated value.

Methods

πŸ»β—οΈ

πŸ– ❗️ 🐻 🎍πŸ₯‘ item Element 

Appends item to the end of the list in O(1).

πŸ½β—οΈ

❗️ 🐽  index πŸ”’ ➑️ ✴️Element

Gets the item at index in O(1). index must be greater than or equal to 0 and less than πŸ“β“ or the program will panic.

🐽➑️

πŸ– ➑️ 🐽 🎍πŸ₯‘ value Element  index πŸ”’ 

Sets value at index. index must be greater than or equal to 0 and less than πŸ“β“ or the program will panic.

πŸ¨β—οΈ

πŸ– ❗️ 🐨  index πŸ”’ ➑️ πŸ‘Œ

Removes the item at index and shifts all following items to the left in O(n).

Returns πŸ‘ unless the index is out of range.

πŸ΅β—οΈ

πŸ– ❗️ 🐡  index πŸ”’ 🎍πŸ₯‘ item Element ➑️ πŸ‘Œ

Inserts the given values before the element with the given index.

All items beginning from index are shifted to the right and item is then inserted at index. Complexity: O(n).

πŸ“β“

❓ πŸ“ ➑️ πŸ”’

Returns the number of items in the list.

πŸ₯❗️

πŸ– ❗️ πŸ₯  list 🍨🐚ElementπŸ† 

Appends the content of list to this list. Complexity: O(n).

πŸΌβ—οΈ

πŸ– ❗️ 🐼 ➑️ 🍬Element

Removes the last item from the list and returns it in O(1). If the list is empty no value is returned.

πŸ—β—οΈ

πŸ– ❗️ πŸ— 

Removes all elements from the list but keeps the list’s capacity.

This can be much more efficient than using a new list. Complexity: O(n).

πŸ΄β—οΈ

πŸ– ❗️ 🐴  capacity πŸ”’ 

Ensures that the list is large enough to store at least capacity elements.

You should use this method if you plan to heavily use 🐷 with large indices in order to avoid automatic, useless allocations.

Complexity: O(n).

πŸ΄β“

❓ 🐴 ➑️ πŸ”’

Returns the lists current capacity.

πŸ¦β—οΈ

πŸ– ❗️ 🦁  comparator πŸ‡ElementElementβž‘οΈπŸ”’πŸ‰ 

Sorts this array in place using the quick sort algorithm.

comparator must return an integer less than, equal to, or greater than 0, if the first argument is considered respectively less than, equal to, or greater than the second.

πŸΉβ—οΈ

πŸ– ❗️ 🐹 

Shuffles the list in place using a Fisher–Yates shuffle.

πŸ°β—οΈ

❗️ 🐰🐚AβšͺοΈπŸ†  callback πŸ‡Element➑️AπŸ‰ ➑️ 🍨🐚AπŸ†

Calls callback with each element in the list and appends the returned value to the end of a new list.

πŸ­β—οΈ

❗️ 🐭  callback πŸ‡Elementβž‘οΈπŸ‘ŒπŸ‰ ➑️ 🍨🐚ElementπŸ†

Returns a new array with all elements that pass the test implemented by callback.

πŸ¦β“

❓ 🐦🐚AπŸ˜›πŸšElementπŸ†πŸ† 🎍πŸ₯‘ value A ➑️ πŸ‘Œ

Returns πŸ‘ if at least one element in the list is equal to value.

πŸ―β—οΈ

❗️ 🐯  callback πŸ‡Elementβž‘οΈπŸ‘ŒπŸ‰ ➑️ πŸ‘Œ

Tests whether all elements in the array pass the test implemented by callback.

The method immdiately returns πŸ‘Ž if callback returned πŸ‘Ž for one element.

πŸ§β—οΈ

❗️ 🐧  callable πŸ‡ElementElement➑️ElementπŸ‰ ➑️ 🍬Element

Combines all elements in this list by using the binary operation described by callable. The first argument is the result of the previous call of the callable, while the first value of the list is used as the initial value and never passed as the second argument.

πŸ€β—οΈ

❗️ 🐀🐚AβšͺοΈπŸ† 🎍πŸ₯‘ start A  callable πŸ‡AElement➑️AπŸ‰ ➑️ A

Combines all elements in this list by using the binary operation described by callable. The first argument is the result of the previous call of the callable, with start used as the initial value passed along with the first element of the list.

πŸ¦”β—οΈ

πŸ– ❗️ πŸ¦” 

Reverses the list in place.

πŸ™Œ

 πŸ™ŒπŸšAπŸ˜›πŸšElementπŸ†πŸ†  other 🍨🐚AπŸ† ➑️ πŸ‘Œ

Tests whether this array and other are equal.

πŸ‘β—οΈ

❗️ 🍑 ➑️ 🌳🐚ElementπŸ†

Returns an iterator to iterate over the elements of this list.