2424 * [ array: setlen ()] ( #array_setlen )
2525 * [ array: reserve ()] ( #array_reserve )
2626 * [ array: tostring ()] ( #array_tostring )
27+ * [ array: equals ()] ( #array_equals )
28+ * [ array: appendfile ()] ( #array_appendfile )
2729
2830<!-- ---------------------------------------------------------------------------------------- -->
2931## Overview
@@ -46,7 +48,7 @@ local carray = require("carray")
4648## Module Functions
4749<!-- ---------------------------------------------------------------------------------------- -->
4850
49- * <a id =" carray_new " >** ` carray.new(type[ , count] )
51+ * <a id =" carray_new " >** `carray.new(type[ , count] )
5052 `** </a >
5153
5254 Creates a new array object with the specified element type.
@@ -109,9 +111,17 @@ to [carray.new()](#carray_new).
109111
110112Array objects can be created by calling the module function [ carray.new()] ( #carray_new ) .
111113
114+ If not other specified, array methods return the array object to allow method chaining,
115+ e.g.
116+ ``` lua
117+ local a = carray .new (" char" ):append (" testdata:" ):appendfile (" test1.data" )
118+ ```
119+ creates a new array with data from string and file content and assigns this array to the
120+ variable * a* .
121+
112122<!-- ---------------------------------------------------------------------------------------- -->
113123
114- * <a id =" array_get " >** ` array: get (pos1[ , pos2] )
124+ * <a id =" array_get " >** `array: get (pos1[ , pos2] )
115125 `** </a >
116126
117127 Get elements from the array.
@@ -128,7 +138,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
128138
129139<!-- ---------------------------------------------------------------------------------------- -->
130140
131- * <a id =" array_set " >** ` array: set (pos, ...)
141+ * <a id =" array_set " >** `array: set (pos, ...)
132142 `** </a >
133143
134144 Sets the given elements at the specified position of the array object.
@@ -147,7 +157,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
147157
148158<!-- ---------------------------------------------------------------------------------------- -->
149159
150- * <a id =" array_append " >** ` array: append (...)
160+ * <a id =" array_append " >** `array: append (...)
151161 `** </a >
152162
153163 Appends the given elements to the end of the array object.
@@ -160,7 +170,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
160170
161171<!-- ---------------------------------------------------------------------------------------- -->
162172
163- * <a id =" array_insert " >** ` array: insert (pos, ...)
173+ * <a id =" array_insert " >** `array: insert (pos, ...)
164174 `** </a >
165175
166176 Inserts the given elements at the specified position of the array object.
@@ -175,7 +185,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
175185
176186<!-- ---------------------------------------------------------------------------------------- -->
177187
178- * <a id =" array_setsub " >** ` array: setsub (pos0, array2, pos1, pos2)
188+ * <a id =" array_setsub " >** `array: setsub (pos0, array2, pos1, pos2)
179189 `** </a >
180190
181191 Sets elements of another array * array2* to the specified position * pos0*
@@ -201,7 +211,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
201211
202212<!-- ---------------------------------------------------------------------------------------- -->
203213
204- * <a id =" array_appendsub " >** ` array: appendsub (array2, pos1, pos2)
214+ * <a id =" array_appendsub " >** `array: appendsub (array2, pos1, pos2)
205215 `** </a >
206216
207217 Appends elements of another array * array2* to the end of the array object.
@@ -222,7 +232,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
222232
223233<!-- ---------------------------------------------------------------------------------------- -->
224234
225- * <a id =" array_insertsub " >** ` array: insertsub (pos0, array2, pos1, pos2)
235+ * <a id =" array_insertsub " >** `array: insertsub (pos0, array2, pos1, pos2)
226236 `** </a >
227237
228238 Inserts elements of another array * array2* to the specified position * pos0*
@@ -246,7 +256,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
246256
247257<!-- ---------------------------------------------------------------------------------------- -->
248258
249- * <a id =" array_remove " >** ` array: remove (pos1[ , pos2] )
259+ * <a id =" array_remove " >** `array: remove (pos1[ , pos2] )
250260 `** </a >
251261
252262 Removes elements from the array.
@@ -264,14 +274,14 @@ Array objects can be created by calling the module function [carray.new()](#carr
264274
265275<!-- ---------------------------------------------------------------------------------------- -->
266276
267- * <a id =" array_len " >** ` array: len ()
277+ * <a id =" array_len " >** `array: len ()
268278 `** </a >
269279
270280 Returns the number of elements in the array object.
271281
272282<!-- ---------------------------------------------------------------------------------------- -->
273283
274- * <a id =" array_type " >** ` array: type ()
284+ * <a id =" array_type " >** `array: type ()
275285 `** </a >
276286
277287 Returns the element type name as string value. Possible values are:
@@ -287,7 +297,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
287297
288298<!-- ---------------------------------------------------------------------------------------- -->
289299
290- * <a id =" array_basetype " >** ` array: basetype ()
300+ * <a id =" array_basetype " >** `array: basetype ()
291301 `** </a >
292302
293303 Returns the element base type name as string value. Possible values are:
@@ -300,7 +310,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
300310
301311<!-- ---------------------------------------------------------------------------------------- -->
302312
303- * <a id =" array_bitwidth " >** ` array: bitwidth ()
313+ * <a id =" array_bitwidth " >** `array: bitwidth ()
304314 `** </a >
305315
306316 Returns the number of bits per element as integer value.
@@ -309,7 +319,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
309319
310320<!-- ---------------------------------------------------------------------------------------- -->
311321
312- * <a id =" array_reset " >** ` array: reset ([ shrink] )
322+ * <a id =" array_reset " >** `array: reset ([ shrink] )
313323 `** </a >
314324
315325 Resets the array to length 0.
@@ -321,7 +331,7 @@ Array objects can be created by calling the module function [carray.new()](#carr
321331
322332<!-- ---------------------------------------------------------------------------------------- -->
323333
324- * <a id =" array_setlen " >** ` array: setlen (newlen[ , shrink] )
334+ * <a id =" array_setlen " >** `array: setlen (newlen[ , shrink] )
325335 `** </a >
326336
327337 Sets how many elements can be stored in the array.
@@ -337,22 +347,23 @@ Array objects can be created by calling the module function [carray.new()](#carr
337347
338348<!-- ---------------------------------------------------------------------------------------- -->
339349
340- * <a id =" array_reserve " >** ` array: reserve ([ count] )
350+ * <a id =" array_reserve " >** `array: reserve ([ count] )
341351 `** </a >
342352
343- Sets or get the reserve count. The reserve count denotes the number of new elements that
353+ Sets or gets the reserve count. The reserve count denotes the number of new elements that
344354 can be appended to the array without the need to re-allocate the array's memory.
345355
346356 * * count* - optional integer, if greater zero this methods assures that the reserve is at
347357 least * count* number of elements. If zero or less the reserve is
348358 released, i.e. the allocated memory for this array object is not greater than
349359 needed for the [ arry: len ()] ( #array_len ) number of elements in this array.
350360
351- This method returns the current reserve count.
361+ This method returns the current reserve count if no argument * count* is given,
362+ otherwise the array object itself is returned to allow method chaining.
352363
353364<!-- ---------------------------------------------------------------------------------------- -->
354365
355- * <a id =" array_tostring " >** ` array: tostring ([ pos1, pos2] )
366+ * <a id =" array_tostring " >** `array: tostring ([ pos1, pos2] )
356367 `** </a >
357368
358369 Returns array elements as string value for arrays that have element type * signed char*
@@ -371,6 +382,24 @@ Array objects can be created by calling the module function [carray.new()](#carr
371382
372383<!-- ---------------------------------------------------------------------------------------- -->
373384
385+ * <a id =" array_equals " >** `array: equals (array2)
386+ `** </a >
387+
388+ Returns * true* if the two arrays are having the same number and type of elements.
389+
390+ <!-- ---------------------------------------------------------------------------------------- -->
391+
392+ * <a id =" array_appendfile " >** `array: appendfile (file[ , pos] )
393+ `** </a >
394+
395+ Appends the content of the given file to the array.
396+
397+ * * file* - a file name string or open file handle.
398+ * * pos* - optional integer, the maximal number of elements that are read from the
399+ given file.
400+
401+ <!-- ---------------------------------------------------------------------------------------- -->
402+
374403[ Lua ] : https://www.lua.org
375404[ Carray C API ] : https://github.com/lua-capis/lua-carray-capi
376405
0 commit comments