ARRAYLIST (RPGLE)

List Implementation : ArrayList
Details ....

Copybooks  

arraylist_h.rpgle
libc_h.rpgle

Procedures  

arraylist_addexported
Add element
arraylist_addAllexported
Add all elements to the arraylist
arraylist_addBooleanexported
Add boolean value to the arraylist
arraylist_addDateexported
Add date value to the arraylist
arraylist_addDecimalexported
Add packed decimal value to the arraylist
arraylist_addDoubleexported
Add double value to the arraylist
arraylist_addFirstexported
Prepend element to the arraylist
arraylist_addFloatexported
Add float value to the arraylist
arraylist_addIntegerexported
Add integer value to the arraylist
arraylist_addLastexported
Append element to the arraylist
arraylist_addLongexported
Add long integer value to the arraylist
arraylist_addShortexported
Add short integer value to the arraylist
arraylist_addStringexported
Add character value to the arraylist
arraylist_clearexported
Clear arraylist
arraylist_containsexported
Contains element
arraylist_copyexported
Create a copy of the arraylist
arraylist_createexported
Create arraylist
arraylist_disposeexported
Dispose arraylist
arraylist_foreachexported
Execute procedure for every arraylist entry
arraylist_frequencyexported
Frequency of element
arraylist_getexported
Get element
arraylist_getBooleanexported
Get boolean value from arraylist
arraylist_getCapacityexported
Get arraylist capacity
arraylist_getDateexported
Get date value from arraylist
arraylist_getDecimalexported
Get packed decimal value from arraylist
arraylist_getDoubleexported
Get dobule value from arraylist
arraylist_getFirstexported
Get first element
arraylist_getFloatexported
Get float value from arraylist
arraylist_getIntegerexported
Get integer value from arraylist
arraylist_getLastexported
Get last element
arraylist_getLongexported
Get long integer value from arraylist
arraylist_getShortexported
Get short integer value from arraylist
arraylist_getSizeexported
Get arraylist size
arraylist_getStringexported
Get character value from arraylist
arraylist_indexOfexported
Get index of element
arraylist_isEmptyexported
Check if arraylist is empty
arraylist_lastIndexOfexported
Get last index of element
arraylist_removeexported
Remove an element
arraylist_removeFirstexported
Remove the first element
arraylist_removeLastexported
Remove the last element
arraylist_removeRangeexported
Remove a range of elements
arraylist_replaceexported
Replace element
arraylist_reverseexported
Reverse order of arraylist entries
arraylist_splitexported
Split character string
arraylist_sublistexported
Create a sublist
arraylist_swapexported
Swap arraylist items
arraylist_toCharArrayexported
To character array
arraylist_toStringexported
Return character representation of arraylist
getEntry
Get entry pointer
increment
Increment array size
moveElements
Push element down by x positions
sendEscapeMessage
Send Escape Message

Detailed Description  

A list implementation with a memory block as backend. The memory for will be dynamically allocated and deallocated. Therefore the list can grow and shrink dynamically as requested.

This list implementation works with a head data structure.

The entries are stored in an "array" which consists of pointers. The pointers of the array store the start address of the memory of the values.

All values are internally null-terminated. So a value of x'00' won't work as expected and should be avoided.

Access to the element is accomplished through accessing the arraylist with an index (position). The index is 0-based. So the first element has an index of 0 (zero).
Author:
Mihael Schmidt
Date:
16.04.2011

Procedure Documentation  

arraylist_add  

voidarraylist_add(Pointer, Pointer, ohne Vorzeichen, ohne Vorzeichen)
Adds an element to the arraylist by copying the content to dynamically allocated memory. Values are stored null-terminated.

If a position is passed the caller must be certain that the position is inside the bounds of the arraylist. If the position is outside of the arraylist an escape message will be sent.
Parameter:
Pointer   constPointer to arraylist
Pointer   constPointer to new entry
Numerisch (ohne Vorzeichen) (10)   constLength of new entry (in byte)
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_addAll  

voidarraylist_addAll(Pointer, Pointer)
Adds all elements from the source arraylist to the destination arraylist.
Parameter:
Pointer   constPointer to the destination arraylist
Pointer   constPointer to the source arraylist
Exported.

arraylist_addBoolean  

voidarraylist_addBoolean(Pointer, Boolean, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a boolean to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Boolean   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addDate  

voidarraylist_addDate(Pointer, Datum, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a date to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Datum   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addDecimal  

voidarraylist_addDecimal(Pointer, Gepackt, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a packed decimal to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (Gepackt) (15,5)   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addDouble  

voidarraylist_addDouble(Pointer, Fliesskommazahl, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a double to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (Fliesskommazahl) (8,)   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addFirst  

voidarraylist_addFirst(Pointer, Pointer, ohne Vorzeichen)
Adds an element to the beginning of the arraylist by copying the content to dynamically allocated memory. Values are stored null-terminated. If the the arraylist is not empty all other elements will be pushed down by one position.
Parameter:
Pointer   constPointer to arraylist
Pointer   constPointer to new entry
Numerisch (ohne Vorzeichen) (10)   constLength of new entry (in byte)
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_addFloat  

voidarraylist_addFloat(Pointer, Fliesskommazahl, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a float to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (Fliesskommazahl) (4,)   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addInteger  

voidarraylist_addInteger(Pointer, Integer, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds an integer to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (Integer) (10)   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addLast  

voidarraylist_addLast(Pointer, Pointer, ohne Vorzeichen)
Adds an element to the end of the arraylist by copying the content to dynamically allocated memory. Values are stored null-terminated.
Parameter:
Pointer   constPointer to arraylist
Pointer   constPointer to new entry
Numerisch (ohne Vorzeichen) (10)   constLength of new entry (in byte)
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_addLong  

voidarraylist_addLong(Pointer, Integer, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a long integer to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (Integer) (20)   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addShort  

voidarraylist_addShort(Pointer, Integer, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a short integer to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (Integer) (5)   constValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_addString  

voidarraylist_addString(Pointer, Zeichen, ohne Vorzeichen)
This procedure is a wrapper for the add procedure and adds a character string to the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Zeichen (65535)   const   varyingValue
Numerisch (ohne Vorzeichen) (10)   const   optionalPosition (default: append)
Exported.

arraylist_clear  

voidarraylist_clear(Pointer)
Deletes all entries. The capacity of the arraylist remains the same.
Parameter:
Pointer   constPointer to the arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_contains  

Booleanarraylist_contains(Pointer, Pointer, ohne Vorzeichen)
Checks if the arraylist contains the passed data. The check will be done byte by byte, so trailing spaces also count.
Parameter:
Pointer   constPointer to the arraylist
Pointer   constPointer to data
Numerisch (ohne Vorzeichen) (10)   constData length
Return value:
Boolean*on if the arraylist contains the data, *off otherwise
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_copy  

Pointerarraylist_copy(Pointer)
Returns a copy of the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Return value:
PointerPointer to the new arraylist
Exported.
Author:
Mihael Schmidt
Date:
2011-04-19

arraylist_create  

Pointerarraylist_create(ohne Vorzeichen, ohne Vorzeichen)
Creates an arraylist.

The initial size is 10. The default increment size is 0 which means with each incrementation the arraylist will double its size.
Parameter:
Numerisch (ohne Vorzeichen) (10)   const   optionalInitial arraylist size (default: 10)
Numerisch (ohne Vorzeichen) (10)   const   optionalIncrementation size (default: 0 - double)
Return value:
PointerPointer to arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_dispose  

voidarraylist_dispose(Pointer)
Disposes the arraylist and all its elements. The pointer will be set to *null.
Parameter:
PointerPointer to arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_foreach  

voidarraylist_foreach(Pointer, Pointer, Pointer)
The passed procedure will be executed for every entry in the arraylist.

The user can pass data through a pointer to the procedure. The pointer will not be touched by this procedure itself, so it can be *null.

The value of list entry can be changed through the passed procedure.

The parameters for the passed procedure are:
  • Pointer to the entry value (const)
  • Value length (const)
  • Pointer to the user data (const)
Parameter:
Pointer   constPointer to the arraylist
Pointer   constProcedure pointer
Pointer   constPointer to user data
Exported.

arraylist_frequency  

ohne Vorzeichenarraylist_frequency(Pointer, Pointer, ohne Vorzeichen)
Returns the number of times the passed element is in the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Pointer   constPointer to data
Numerisch (ohne Vorzeichen) (10)   constData length
Return value:
Numerisch (ohne Vorzeichen) (10)frequency of the passed data in the arraylist
Exported.
Author:
Mihael Schmidt
Date:
2011-04-19

arraylist_get  

Pointerarraylist_get(Pointer, ohne Vorzeichen)
Returns a pointer to the elment at the given position. The element is null-terminated. Changes to the element through the returned pointer is not recommended. Use the appropriate procedures instead.

If the requested element position is not in the arraylist then an escape message will be sent.
Parameter:
Pointer   constPointer to arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
PointerPointer to the null-terminated element or *null if arraylist is empty
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_getBoolean  

Booleanarraylist_getBoolean(Pointer, ohne Vorzeichen)
Returns the previously inserted boolean value from the arraylist. If the value cannot be interpreted as a boolean an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
BooleanValue
Exported.

arraylist_getCapacity  

ohne Vorzeichenarraylist_getCapacity(Pointer)
Returns the number of elements which can be stored in the current arraylist.
Parameter:
Pointer   constPointer to arraylist
Return value:
Numerisch (ohne Vorzeichen) (10)Number of elements able to store in the arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_getDate  

Datumarraylist_getDate(Pointer, ohne Vorzeichen)
Returns the previously inserted date value from the arraylist. If the value cannot be interpreted as a date an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
DatumValue
Exported.

arraylist_getDecimal  

Gepacktarraylist_getDecimal(Pointer, ohne Vorzeichen)
Returns the previously inserted packed decimal value from the arraylist. If the value cannot be interpreted as a packed decimal an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
Numerisch (Gepackt) (15,5)Value
Exported.

arraylist_getDouble  

Fliesskommazahlarraylist_getDouble(Pointer, ohne Vorzeichen)
Returns the previously inserted double value from the arraylist. If the value cannot be interpreted as a double an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
Numerisch (Fliesskommazahl) (8,)Value
Exported.

arraylist_getFirst  

Pointerarraylist_getFirst(Pointer)
Returns a pointer to the first elment in the arraylist. The element is null-terminated. Changes to the element through the returned pointer is not recommended. Use the appropriate procedures instead.
Parameter:
Pointer   constPointer to arraylist
Return value:
PointerPointer to the null-terminated element or *null if the arraylist is empty
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_getFloat  

Fliesskommazahlarraylist_getFloat(Pointer, ohne Vorzeichen)
Returns the previously inserted float value from the arraylist. If the value cannot be interpreted as a float an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
Numerisch (Fliesskommazahl) (4,)Value
Exported.

arraylist_getInteger  

Integerarraylist_getInteger(Pointer, ohne Vorzeichen)
Returns the previously inserted integer value from the arraylist. If the value cannot be interpreted as an integer an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
Numerisch (Integer) (10)Value
Exported.

arraylist_getLast  

Pointerarraylist_getLast(Pointer)
Returns a pointer to the last elment in the arraylist. The element is null-terminated. Changes to the element through the returned pointer is not recommended. Use the appropriate procedures instead.
Parameter:
Pointer   constPointer to arraylist
Return value:
PointerPointer to the null-terminated element or *null if the arraylist is empty
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_getLong  

Integerarraylist_getLong(Pointer, ohne Vorzeichen)
Returns the previously inserted long integer value from the arraylist. If the value cannot be interpreted as a long integer an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
Numerisch (Integer) (20)Value
Exported.

arraylist_getShort  

Integerarraylist_getShort(Pointer, ohne Vorzeichen)
Returns the previously inserted short integer value from the arraylist. If the value cannot be interpreted as a short integer an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
Numerisch (Integer) (5)Value
Exported.

arraylist_getSize  

ohne Vorzeichenarraylist_getSize(Pointer)
Returns the number of elements currently in the arraylist.
Parameter:
Pointer   constPointer to arraylist
Return value:
Numerisch (ohne Vorzeichen) (10)Number of elements in the arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_getString  

Zeichenarraylist_getString(Pointer, ohne Vorzeichen)
Returns the previously inserted character string value from the arraylist. If the value cannot be interpreted as a char value an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constPosition
Return value:
Zeichen (65535)Value
Exported.

arraylist_indexOf  

Integerarraylist_indexOf(Pointer, Pointer, ohne Vorzeichen)
Returns the index of the passed element.
Parameter:
Pointer   constPointer to the arraylist
Pointer   constPointer to data
Numerisch (ohne Vorzeichen) (10)   constData length
Return value:
Numerisch (Integer) (10)index of the element or -1 if the element is not in the arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_isEmpty  

Booleanarraylist_isEmpty(Pointer)
Checks if the arraylist is empty.
Parameter:
Pointer   constPointer to the arraylist
Return value:
Boolean*on = arraylist is empty
*off = arraylist is not empty
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_lastIndexOf  

Integerarraylist_lastIndexOf(Pointer, Pointer, ohne Vorzeichen)
Returns the last index of the passed element.
Parameter:
Pointer   constPointer to the arraylist
Pointer   constPointer to data
Numerisch (ohne Vorzeichen) (10)   constData length
Return value:
Numerisch (Integer) (10)last index of the element or -1 if the element is not in the arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_remove  

voidarraylist_remove(Pointer, ohne Vorzeichen)
Removes an element from the arraylist. If the given position is outside of the bounds of the arraylist an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constElement index to be removed
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_removeFirst  

voidarraylist_removeFirst(Pointer)
Removes the first element from the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_removeLast  

voidarraylist_removeLast(Pointer)
Removes the last element from the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_removeRange  

voidarraylist_removeRange(Pointer, ohne Vorzeichen, ohne Vorzeichen)
Removes a range of elements from the arraylist. The range must be inside the bounds of the arraylist. If the range is outside the arraylist an escape message will be sent.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constRange starting index
Numerisch (ohne Vorzeichen) (10)   constNumber of elements to remove
Exported.
Author:
Mihael Schmidt
Date:
16.04.2011

arraylist_replace  

voidarraylist_replace(Pointer, ohne Vorzeichen, Pointer, ohne Vorzeichen)
Replaces the given element with the new data.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constIndex to data which should be replaced
Pointer   constPointer to the new data
Numerisch (ohne Vorzeichen) (10)   constLength of the new data
Exported.
Author:
Mihael Schmidt
Date:
2011-04-19

arraylist_reverse  

voidarraylist_reverse(Pointer)
Reverses the order of the entries of the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Exported.

arraylist_split  

Pointerarraylist_split(Zeichen, Zeichen)
The passed character string will be split into tokens by either a passed or the default separator. All tokens will be added to a new arraylist which will be returned.

Empty (but not blank) values will be dropped silently.
Parameter:
Zeichen (65535)   const   varyingCharacter string (null-terminated)
Zeichen (1)   const   optionalSeparator (default: ;)
Return value:
PointerPointer to the filled arraylist
Exported.
Author:
Mihael Schmidt
Date:
26.01.2009

arraylist_sublist  

Pointerarraylist_sublist(Pointer)
Returns a sublist of this arraylist.
Parameter:
Pointer   constPointer to the arraylist
Return value:
PointerPointer to the new arraylist (sublist)
Exported.
Author:
Mihael Schmidt
Date:
2011-04-19

arraylist_swap  

voidarraylist_swap(Pointer, ohne Vorzeichen, ohne Vorzeichen)
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constItem to swap
Numerisch (ohne Vorzeichen) (10)   constItem to swap
Exported.
Author:
Mihael Schmidt
Date:
2011-04-19

arraylist_toCharArray  

voidarraylist_toCharArray(Pointer, Pointer, ohne Vorzeichen, ohne Vorzeichen)
Copies all entries of this arraylist to the passed array. Entries will be truncated if they are too big for the array. If the array is not big enough, the last entries will be silently dropped.
Parameter:
Pointer   constPointer to the arraylist
Pointer   constPointer to the array
Numerisch (ohne Vorzeichen) (10)   constElement count
Numerisch (ohne Vorzeichen) (10)   constElement length
Exported.

arraylist_toString  

Zeichenarraylist_toString(Pointer, Zeichen, Zeichen, Zeichen)
Returns a string with the arraylist items separated either by the passed or default separator. The items can be enclosed by a passed character. The maximum character length returned is 65535. Every character/item after that will be dropped silently. Items will not be trimmed for this operation.

If the third parameter is passed, the third parameter will be pre- and appended to the item. If the fourth parameter is also passed the third parameter will be prepended to the item and the fourth parameter will be appended to the item.
Parameter:
Pointer   constPointer to the arraylist
Zeichen (1)   const   optional   omissibleseparator (default: ,)
Zeichen (100)   const   varying   optionalenclosing character (default: nothing)
Zeichen (100)   const   varying   optionalenclosing character at the end of item (default: nothing)
Return value:
Zeichen (65535)character representation of all arraylist items
Exported.

getEntry  

PointergetEntry(Pointer, Integer)
Returns the pointer of an entry.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (Integer) (10)   constPosition (zero-based)
Return value:
PointerPointer to arraylist entry or *null
Author:
Mihael Schmidt
Date:
23.06.2008

increment  

voidincrement(Pointer, ohne Vorzeichen)
Increases the size of the arraylist either by 2 or up to the passed size. The arraylist size will be decreased if the given size is lower than the current size.

If the new size cannot be less than the number of elements currently in the arraylist.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   const   optionalNew size of the arraylist (default: determined by the header)
Author:
Mihael Schmidt
Date:
23.06.2008

moveElements  

voidmoveElements(Pointer, ohne Vorzeichen)
Moves the passed element up or down by the x number of entries. This procedure also pushes/pulls every element under it also up or down by the given number of positions.

A positive downBy value will push the entries down. A negative downBy value will pull the entries up.
Parameter:
Pointer   constPointer to the arraylist
Numerisch (ohne Vorzeichen) (10)   constNumber of positions to go up or down (default: 1 = down by one position)
Author:
Mihael Schmidt
Date:
30.07.2008

sendEscapeMessage  

voidsendEscapeMessage(Zeichen)
Sends an escape message with the specified Id.
Parameter:
Zeichen (65535)   const   varyingMessage Id
Author:
Mihael Schmidt
Date:
23.06.2008