568 lines
11 KiB
HTML
568 lines
11 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>Luadocs for utils/arrayutil.lua</title>
|
|
<link rel="stylesheet" href="../../luadoc.css" type="text/css" />
|
|
<!--meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/-->
|
|
</head>
|
|
|
|
<body>
|
|
<div id="container">
|
|
|
|
<div id="product">
|
|
<div id="product_logo"></div>
|
|
<div id="product_name"><big><b></b></big></div>
|
|
<div id="product_description"></div>
|
|
</div> <!-- id="product" -->
|
|
|
|
<div id="main">
|
|
|
|
<div id="navigation">
|
|
|
|
|
|
<h1>LuaDoc</h1>
|
|
<ul>
|
|
|
|
<li><a href="../../index.html">Index</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
<!-- Module list -->
|
|
|
|
|
|
|
|
<!-- File list -->
|
|
|
|
<h1>Files</h1>
|
|
<ul>
|
|
|
|
<li><strong>utils/arrayutil.lua</strong></li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/blockedcache.html">utils/blockedcache.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/blockutil.html">utils/blockutil.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/color.html">utils/color.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/constants.html">utils/constants.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/fisheryates.html">utils/fisheryates.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/init.html">utils/init.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/interpolate.html">utils/interpolate.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/inventoryutil.html">utils/inventoryutil.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/list.html">utils/list.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/log.html">utils/log.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/mapmanipulator.html">utils/mapmanipulator.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/mathutil.html">utils/mathutil.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/noisemanager.html">utils/noisemanager.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/pathutil.html">utils/pathutil.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/stopwatch.html">utils/stopwatch.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/stringutil.html">utils/stringutil.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/tableutil.html">utils/tableutil.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/tango.html">utils/tango.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/test.html">utils/test.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/textureutil.html">utils/textureutil.lua</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="../../files/utils/transform.html">utils/transform.lua</a>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> <!-- id="navigation" -->
|
|
|
|
<div id="content">
|
|
|
|
<h1>File <code>utils/arrayutil.lua</code></h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>Functions</h2>
|
|
<table class="function_list">
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.contains">arrayutil.contains</a> (array, item, equals)</td>
|
|
<td class="summary">Gets if the given array contains the given item.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.index">arrayutil.index</a> (array, item, equals)</td>
|
|
<td class="summary">Gets the index of the item in the given array.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.next_matching_column">arrayutil.next_matching_column</a> (array, start_index, matcher, reverse)</td>
|
|
<td class="summary">Finds the next matching column.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.next_matching_row">arrayutil.next_matching_row</a> (array, start_index, matcher, reverse)</td>
|
|
<td class="summary">Finds the next matching row.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.previous_matching_column">arrayutil.previous_matching_column</a> (array, start_index, matcher)</td>
|
|
<td class="summary">Finds the previous matching column.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.previous_matching_row">arrayutil.previous_matching_row</a> (array, start_index, matcher)</td>
|
|
<td class="summary">Finds the previous matching row.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.reduce2d">arrayutil.reduce2d</a> (array, is_empty)</td>
|
|
<td class="summary">Removes empty rows and columns at the beginning and the end of the given array.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.swapped_reindex2d">arrayutil.swapped_reindex2d</a> (data, new_x, new_y)</td>
|
|
<td class="summary">Reindexes the given 2D array, swapping the two dimensions.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="name" nowrap><a href="#arrayutil.swapped_reindex3d">arrayutil.swapped_reindex3d</a> (data, new_x, new_y, new_z)</td>
|
|
<td class="summary">Reindexes the given 3d array, swapping the two dimensions.</td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<br/>
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
<h2><a name="functions"></a>Functions</h2>
|
|
<dl class="function">
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.contains"></a><strong>arrayutil.contains</strong> (array, item, equals)</dt>
|
|
<dd>
|
|
Gets if the given array contains the given item.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
array: The array to search in.
|
|
</li>
|
|
|
|
<li>
|
|
item: The item to search for, can either be an item or another array.
|
|
</li>
|
|
|
|
<li>
|
|
equals: Optional. The function to determine if items equal each other, defaults to tableutil.equals.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
true if the array contains the given item.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.index"></a><strong>arrayutil.index</strong> (array, item, equals)</dt>
|
|
<dd>
|
|
Gets the index of the item in the given array.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
array: The array to search in.
|
|
</li>
|
|
|
|
<li>
|
|
item: The item to search for, can either be an item or another array.
|
|
</li>
|
|
|
|
<li>
|
|
equals: Optional. The function to determine if items equal each other, defaults to tableutil.equals.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
The index of the given item or array, -1 if it was not found.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.next_matching_column"></a><strong>arrayutil.next_matching_column</strong> (array, start_index, matcher, reverse)</dt>
|
|
<dd>
|
|
Finds the next matching column.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
array: The 2D array to search.
|
|
</li>
|
|
|
|
<li>
|
|
start_index: Optional. The index at which to start. Defaults to 1, or if the direction is reversed, the number of columns in the array.
|
|
</li>
|
|
|
|
<li>
|
|
matcher: Optional. The function that is used to determine if the column matches or not. Is expected to take one argument, the item, and return a boolean. The column matches if any of its items matches this condition. Defaults to not nil and not empty string.
|
|
</li>
|
|
|
|
<li>
|
|
reverse: Optional. If the array should be serched backwards. Defaults to false.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
The index of the matching column. -1 if none was found.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.next_matching_row"></a><strong>arrayutil.next_matching_row</strong> (array, start_index, matcher, reverse)</dt>
|
|
<dd>
|
|
Finds the next matching row.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
array: The 2D array to search.
|
|
</li>
|
|
|
|
<li>
|
|
start_index: Optional. The index at which to start. Defaults to 1, or if the direction is reversed, the number of rows in the array.
|
|
</li>
|
|
|
|
<li>
|
|
matcher: Optional. The function that is used to determine if the row matches or not. Is expected to take one argument, the item, and return a boolean. The row matches if any of its items matches this condition. Defaults to not nil and not empty string.
|
|
</li>
|
|
|
|
<li>
|
|
reverse: Optional. If the array should be serched backwards. Defaults to false.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
The index of the matching row. -1 if none was found.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.previous_matching_column"></a><strong>arrayutil.previous_matching_column</strong> (array, start_index, matcher)</dt>
|
|
<dd>
|
|
Finds the previous matching column.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
array: The 2D array to search.
|
|
</li>
|
|
|
|
<li>
|
|
start_index: Optional. The index at which to start. Defaults to the number columns in the array.
|
|
</li>
|
|
|
|
<li>
|
|
matcher: Optional. The function that is used to determine if the column matches or not. Is expected to take one argument, the item, and return a boolean. The column matches if any of its items matches this condition. Defaults to not nil and not empty string.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
The index of the matching column. -1 if none was found.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.previous_matching_row"></a><strong>arrayutil.previous_matching_row</strong> (array, start_index, matcher)</dt>
|
|
<dd>
|
|
Finds the previous matching row.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
array: The 2D array to search.
|
|
</li>
|
|
|
|
<li>
|
|
start_index: Optional. The index at which to start. Defaults to the number rows in the array.
|
|
</li>
|
|
|
|
<li>
|
|
matcher: Optional. The function that is used to determine if the row matches or not. Is expected to take one argument, the item, and return a boolean. The row matches if any of its items matches this condition. Defaults to not nil and not empty string.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
The index of the matching row. -1 if none was found.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.reduce2d"></a><strong>arrayutil.reduce2d</strong> (array, is_empty)</dt>
|
|
<dd>
|
|
Removes empty rows and columns at the beginning and the end of the given array.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
array: The array.
|
|
</li>
|
|
|
|
<li>
|
|
is_empty: Optional. The function used for determining if the item is empty. By default nil and an empty string is considered empty. Expected is a function that takes one item and returns a boolean.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.swapped_reindex2d"></a><strong>arrayutil.swapped_reindex2d</strong> (data, new_x, new_y)</dt>
|
|
<dd>
|
|
Reindexes the given 2D array, swapping the two dimensions.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
data: The array to reindex.
|
|
</li>
|
|
|
|
<li>
|
|
new_x: The new startpoint for the first dimension.
|
|
</li>
|
|
|
|
<li>
|
|
new_y: The new startpoint for the second dimension.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
The reindexed array.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
<dt><a name="arrayutil.swapped_reindex3d"></a><strong>arrayutil.swapped_reindex3d</strong> (data, new_x, new_y, new_z)</dt>
|
|
<dd>
|
|
Reindexes the given 3d array, swapping the two dimensions.
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
<ul>
|
|
|
|
<li>
|
|
data: The array to reindex.
|
|
</li>
|
|
|
|
<li>
|
|
new_x: The new startpoint for the first dimension.
|
|
</li>
|
|
|
|
<li>
|
|
new_y: The new startpoint for the second dimension.
|
|
</li>
|
|
|
|
<li>
|
|
new_z: The new startpoint for the third dimension.
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h3>Return value:</h3>
|
|
The reindexed array.
|
|
|
|
|
|
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div> <!-- id="content" -->
|
|
|
|
</div> <!-- id="main" -->
|
|
|
|
<div id="about">
|
|
<p><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a></p>
|
|
</div> <!-- id="about" -->
|
|
|
|
</div> <!-- id="container" -->
|
|
</body>
|
|
</html>
|