VECTOR   (RPGLE)

List Implementation : Vector
More ....

Procedures  [top]

getVectorEntry  
Get entry pointer
increment  
Increment array size
isVectorImpl  
Check for vector implementation
moveElements  
Push element down by x positions
sendEscapeMessage  
Send Escape Message
vector_add exported
Add element
vector_addAll exported
Add all elements to the vector
vector_addBoolean exported
Add boolean value to the vector
vector_addDate exported
Add date value to the vector
vector_addDecimal exported
Add packed decimal value to the vector
vector_addDouble exported
Add double value to the vector
vector_addFirst exported
Prepend element to the vector
vector_addFloat exported
Add float value to the vector
vector_addInteger exported
Add integer value to the vector
vector_addLast exported
Append element to the vector
vector_addLong exported
Add long integer value to the vector
vector_addShort exported
Add short integer value to the vector
vector_addString exported
Add character value to the vector
vector_clear exported
Clear vector
vector_contains exported
Contains element
vector_copy exported
Create a copy of the vector
vector_create exported
Create vector
vector_dispose exported
Dispose vector
vector_foreach exported
Execute procedure for every vector entry
vector_frequency exported
Frequency of element
vector_get exported
Get element
vector_getBoolean exported
Get boolean value from vector
vector_getCapacity exported
Get vector capacity
vector_getDate exported
Get date value from vector
vector_getDecimal exported
Get packed decimal value from vector
vector_getDouble exported
Get dobule value from vector
vector_getFirst exported
Get first element
vector_getFloat exported
Get float value from vector
vector_getInteger exported
Get integer value from vector
vector_getLast exported
Get last element
vector_getLong exported
Get long integer value from vector
vector_getShort exported
Get short integer value from vector
vector_getSize exported
Get vector size
vector_getString exported
Get character value from vector
vector_indexOf exported
Get index of element
vector_isEmpty exported
Check if vector is empty
vector_lastIndexOf exported
Get last index of element
vector_remove exported
Remove an element
vector_removeFirst exported
Remove the first element
vector_removeLast exported
Remove the last element
vector_removeRange exported
Remove a range of elements
vector_replace exported
Replace element
vector_reverse exported
Reverse order of vector entries
vector_split exported
Split character string
vector_sublist exported
Create a sublist
vector_swap exported
Swap vector items
vector_toCharArray exported
To character array
vector_toString exported
Return character representation of vector

Copybooks  [top]

VECTOR_H
CEEAPI_H

Detailed Description  [top]

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.

A user created storage heap will be used for memory allocation / deallocation.

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 vector with an index (position). The index is 0-based. So the first element has an index of 0 (zero).
Author:
Mihael Schmidt
Date:
23.06.2008


Procedure Documentation  [top]

getVectorEntry  [top]

Pointer getVectorEntry ( Pointer, Integer )
Returns the pointer of an entry.
Parameters:
Pointer Pointer to the vector
Numeric (Integer) (10) Position (zero-based)
Return value:
Pointer Pointer to vector entry or *null
Author:
Mihael Schmidt
Date:
23.06.2008

increment  [top]

increment ( Pointer, Unsigned )
Increases the size of the vector either by 2 or up to the passed size. The vector 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 vector.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) New size of the vector (default: determined by the header)
Author:
Mihael Schmidt
Date:
23.06.2008

isVectorImpl  [top]

isVectorImpl ( Pointer )
Checks if the pointer points to a vector. The memory of the vector implementation of this service program has an id in the first 20 bytes of the header.

If the pointer does not point to a vector an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Author:
Mihael Schmidt
Date:
23.06.2008

moveElements  [top]

moveElements ( Pointer, Unsigned, Integer )
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.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Number of positions to go up or down (default: 1 = down by one position)
Numeric (Integer) (10)
Author:
Mihael Schmidt
Date:
30.07.2008

sendEscapeMessage  [top]

sendEscapeMessage ( Integer )
Sends an escape message with the specified Id.
Parameters:
Numeric (Integer) (10) Message Id
Author:
Mihael Schmidt
Date:
23.06.2008

vector_add  [top]

vector_add ( Pointer, Pointer, Unsigned, Unsigned )
Adds an element to the vector 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 vector. If the position is outside of the vector an escape message will be sent.
Parameters:
Pointer Pointer to vector
Pointer Pointer to new entry
Numeric (Unsigned) (10) Length of new entry (in byte)
Numeric (Unsigned) (10) Position
Exported.
Author:
Mihael Schmidt
Date:
04.07.2008

vector_addAll  [top]

vector_addAll ( Pointer, Pointer )
Adds all elements from the source vector to the destination vector.
Parameters:
Pointer Pointer to the destination vector
Pointer Pointer to the source vector
Exported.

vector_addBoolean  [top]

vector_addBoolean ( Pointer, Boolean, Unsigned )
This procedure is a wrapper for the add procedure and adds a boolean to the vector.
Parameters:
Pointer Pointer to the vector
Boolean Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addDate  [top]

vector_addDate ( Pointer, Date, Unsigned )
This procedure is a wrapper for the add procedure and adds a date to the vector.
Parameters:
Pointer Pointer to the vector
Date Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addDecimal  [top]

vector_addDecimal ( Pointer, Packed, Unsigned )
This procedure is a wrapper for the add procedure and adds a packed decimal to the vector.
Parameters:
Pointer Pointer to the vector
Numeric (Packed) (15,5) Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addDouble  [top]

vector_addDouble ( Pointer, Float, Unsigned )
This procedure is a wrapper for the add procedure and adds a double to the vector.
Parameters:
Pointer Pointer to the vector
Numeric (Float) (8,) Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addFirst  [top]

vector_addFirst ( Pointer, Pointer, Unsigned )
Adds an element to the beginning of the vector by copying the content to dynamically allocated memory. Values are stored null-terminated. If the the vector is not empty all other elements will be pushed down by one position.
Parameters:
Pointer Pointer to vector
Pointer Pointer to new entry
Numeric (Unsigned) (10) Length of new entry (in byte)
Exported.
Author:
Mihael Schmidt
Date:
30.07.2008

vector_addFloat  [top]

vector_addFloat ( Pointer, Float, Unsigned )
This procedure is a wrapper for the add procedure and adds a float to the vector.
Parameters:
Pointer Pointer to the vector
Numeric (Float) (4,) Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addInteger  [top]

vector_addInteger ( Pointer, Integer, Unsigned )
This procedure is a wrapper for the add procedure and adds an integer to the vector.
Parameters:
Pointer Pointer to the vector
Numeric (Integer) (10) Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addLast  [top]

vector_addLast ( Pointer, Pointer, Unsigned )
Adds an element to the end of the vector by copying the content to dynamically allocated memory. Values are stored null-terminated.
Parameters:
Pointer Pointer to vector
Pointer Pointer to new entry
Numeric (Unsigned) (10) Length of new entry (in byte)
Exported.
Author:
Mihael Schmidt
Date:
27.07.2008

vector_addLong  [top]

vector_addLong ( Pointer, Integer, Unsigned )
This procedure is a wrapper for the add procedure and adds a long integer to the vector.
Parameters:
Pointer Pointer to the vector
Numeric (Integer) (20) Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addShort  [top]

vector_addShort ( Pointer, Integer, Unsigned )
This procedure is a wrapper for the add procedure and adds a short integer to the vector.
Parameters:
Pointer Pointer to the vector
Numeric (Integer) (5) Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_addString  [top]

vector_addString ( Pointer, Character, Unsigned )
This procedure is a wrapper for the add procedure and adds a character string to the vector.
Parameters:
Pointer Pointer to the vector
Character (65535) Value
Numeric (Unsigned) (10) Position (default: append)
Exported.

vector_clear  [top]

vector_clear ( Pointer )
Deletes all entries. The capacity of the vector remains the same.
Parameters:
Pointer Pointer to the vector
Exported.
Author:
Mihael Schmidt
Date:
27.07.2008

vector_contains  [top]

Boolean vector_contains ( Pointer, Pointer, Unsigned )
Checks if the vector contains the passed data. The check will be done byte by byte, so trailing spaces also count.
Parameters:
Pointer Pointer to the vector
Pointer Pointer to data
Numeric (Unsigned) (10) Data length
Return value:
Boolean *on if the vector contains the data, *off otherwise
Exported.
Author:
Mihael Schmidt
Date:
26.11.2008

vector_copy  [top]

Pointer vector_copy ( Pointer )
Returns a copy of the vector.
Parameters:
Pointer Pointer to the vector
Return value:
Pointer Pointer to the new vector
Exported.
Author:
Mihael Schmidt
Date:
26.11.2008

vector_create  [top]

Pointer vector_create ( Unsigned, Unsigned )
Creates a vector.

The initial size is 10. The default increment size is 0 which means with each incrementation the vector will double its size.
Parameters:
Numeric (Unsigned) (10) Initial vector size (default: 10)
Numeric (Unsigned) (10) Incrementation size (default: 0 - double)
Return value:
Pointer Pointer to vector
Exported.
Author:
Mihael Schmidt
Date:
04.07.2008

vector_dispose  [top]

vector_dispose ( Pointer )
Disposes the vector and all its elements. The pointer will be set to *null.
Parameters:
Pointer Pointer to vector
Exported.
Author:
Mihael Schmidt
Date:
04.07.2008

vector_foreach  [top]

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

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)
  • Pointer to the user data (const)
Parameters:
Pointer Pointer to the vector
Pointer Procedure pointer
Pointer Pointer to user data
Exported.
Author:
Mihael Schmidt
Date:
20.01.2009

vector_frequency  [top]

Unsigned vector_frequency ( Pointer, Pointer, Unsigned )
Returns the number of times the passed element is in the vector.
Parameters:
Pointer Pointer to the vector
Pointer Pointer to data
Numeric (Unsigned) (10) Data length
Return value:
Numeric (Unsigned) (10) frequency of the passed data in the vector
Exported.
Author:
Mihael Schmidt
Date:
26.11.2008

vector_get  [top]

Pointer vector_get ( Pointer, Unsigned )
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 vector then an escape message will be sent.
Parameters:
Pointer Pointer to vector
Numeric (Unsigned) (10) Position
Return value:
Pointer Pointer to the null-terminated element or *null if vector is empty
Exported.
Author:
Mihael Schmidt
Date:
05.07.2008

vector_getBoolean  [top]

Boolean vector_getBoolean ( Pointer, Unsigned )
Returns the previously inserted boolean value from the vector. If the value cannot be interpreted as a boolean an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Boolean Value
Exported.

vector_getCapacity  [top]

Unsigned vector_getCapacity ( Pointer )
Returns the number of elements which can be stored in the current vector.
Parameters:
Pointer Pointer to vector
Return value:
Numeric (Unsigned) (10) Number of elements able to store in the vector
Exported.
Author:
Mihael Schmidt
Date:
24.07.2008

vector_getDate  [top]

Date vector_getDate ( Pointer, Unsigned )
Returns the previously inserted date value from the vector. If the value cannot be interpreted as a date an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Date Value
Exported.

vector_getDecimal  [top]

Packed vector_getDecimal ( Pointer, Unsigned )
Returns the previously inserted packed decimal value from the vector. If the value cannot be interpreted as a packed decimal an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Numeric (Packed) (15,5) Value
Exported.

vector_getDouble  [top]

Float vector_getDouble ( Pointer, Unsigned )
Returns the previously inserted double value from the vector. If the value cannot be interpreted as a double an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Numeric (Float) (8,) Value
Exported.

vector_getFirst  [top]

Pointer vector_getFirst ( Pointer )
Returns a pointer to the first elment in the vector. The element is null-terminated. Changes to the element through the returned pointer is not recommended. Use the appropriate procedures instead.
Parameters:
Pointer Pointer to vector
Return value:
Pointer Pointer to the null-terminated element or *null if the vector is empty
Exported.
Author:
Mihael Schmidt
Date:
03.08.2008

vector_getFloat  [top]

Float vector_getFloat ( Pointer, Unsigned )
Returns the previously inserted float value from the vector. If the value cannot be interpreted as a float an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Numeric (Float) (4,) Value
Exported.

vector_getInteger  [top]

Integer vector_getInteger ( Pointer, Unsigned )
Returns the previously inserted integer value from the vector. If the value cannot be interpreted as an integer an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Numeric (Integer) (10) Value
Exported.

vector_getLast  [top]

Pointer vector_getLast ( Pointer )
Returns a pointer to the last elment in the vector. The element is null-terminated. Changes to the element through the returned pointer is not recommended. Use the appropriate procedures instead.
Parameters:
Pointer Pointer to vector
Return value:
Pointer Pointer to the null-terminated element or *null if the vector is empty
Exported.
Author:
Mihael Schmidt
Date:
03.08.2008

vector_getLong  [top]

Integer vector_getLong ( Pointer, Unsigned )
Returns the previously inserted long integer value from the vector. If the value cannot be interpreted as a long integer an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Numeric (Integer) (20) Value
Exported.

vector_getShort  [top]

Integer vector_getShort ( Pointer, Unsigned )
Returns the previously inserted short integer value from the vector. If the value cannot be interpreted as a short integer an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Numeric (Integer) (5) Value
Exported.

vector_getSize  [top]

Unsigned vector_getSize ( Pointer )
Returns the number of elements currently in the vector.
Parameters:
Pointer Pointer to vector
Return value:
Numeric (Unsigned) (10) Number of elements in the vector
Exported.
Author:
Mihael Schmidt
Date:
24.07.2008

vector_getString  [top]

Character vector_getString ( Pointer, Unsigned )
Returns the previously inserted character string value from the vector. If the value cannot be interpreted as a char value an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Position
Return value:
Character (65535) Value
Exported.

vector_indexOf  [top]

Integer vector_indexOf ( Pointer, Pointer, Unsigned )
Returns the index of the passed element.
Parameters:
Pointer Pointer to the vector
Pointer Pointer to data
Numeric (Unsigned) (10) Data length
Return value:
Numeric (Integer) (10) index of the element or -1 if the element is not in the vector
Exported.
Author:
Mihael Schmidt
Date:
26.11.2008

vector_isEmpty  [top]

Boolean vector_isEmpty ( Pointer )
Checks if the vector is empty.
Parameters:
Pointer Pointer to the vector
Return value:
Boolean *on = vector is empty
*off = vector is not empty
Exported.
Author:
Mihael Schmidt
Date:
27.07.2008

vector_lastIndexOf  [top]

Integer vector_lastIndexOf ( Pointer, Pointer, Unsigned )
Returns the last index of the passed element.
Parameters:
Pointer Pointer to the vector
Pointer Pointer to data
Numeric (Unsigned) (10) Data length
Return value:
Numeric (Integer) (10) last index of the element or -1 if the element is not in the vector
Exported.
Author:
Mihael Schmidt
Date:
26.11.2008

vector_remove  [top]

vector_remove ( Pointer, Unsigned )
Removes an element from the vector. If the given position is outside of the bounds of the vector an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Element index to be removed
Exported.
Author:
Mihael Schmidt
Date:
01.08.2008

vector_removeFirst  [top]

vector_removeFirst ( Pointer )
Removes the first element from the vector.
Parameters:
Pointer Pointer to the vector
Exported.
Author:
Mihael Schmidt
Date:
01.08.2008

vector_removeLast  [top]

vector_removeLast ( Pointer )
Removes the last element from the vector.
Parameters:
Pointer Pointer to the vector
Exported.
Author:
Mihael Schmidt
Date:
01.08.2008

vector_removeRange  [top]

vector_removeRange ( Pointer, Unsigned, Unsigned )
Removes a range of elements from the vector. The range must be inside the bounds of the vector. If the range is outside the vector an escape message will be sent.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Range starting index
Numeric (Unsigned) (10) Number of elements to remove
Exported.
Author:
Mihael Schmidt
Date:
01.08.2008

vector_replace  [top]

vector_replace ( Pointer, Unsigned, Pointer, Unsigned )
Replaces the given element with the new data.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Index to data which should be replaced
Pointer Pointer to the new data
Numeric (Unsigned) (10) Length of the new data
Exported.
Author:
Mihael Schmidt
Date:
26.11.2008

vector_reverse  [top]

vector_reverse ( Pointer )
Reverses the order of the entries of the vector.
Parameters:
Pointer Pointer to the vector
Exported.
Author:
Mihael Schmidt
Date:
24.01.2009

vector_split  [top]

Pointer vector_split ( Character, Character )
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 vector which will be returned.

Empty (but not blank) values will be dropped silently.
Parameters:
Character (65535) Character string (null-terminated)
Character (1) Separator (default: ;)
Return value:
Pointer Pointer to the filled vector
Exported.
Author:
Mihael Schmidt
Date:
26.01.2009

vector_sublist  [top]

Pointer vector_sublist ( Pointer, Unsigned, Unsigned )
Returns a sublist of this vector.
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10)
Numeric (Unsigned) (10)
Return value:
Pointer Pointer to the new vector (sublist)
Exported.
Author:
Mihael Schmidt
Date:
26.11.2008

vector_swap  [top]

vector_swap ( Pointer, Unsigned, Unsigned )
Parameters:
Pointer Pointer to the vector
Numeric (Unsigned) (10) Item to swap
Numeric (Unsigned) (10) Item to swap
Exported.
Author:
Mihael Schmidt
Date:
11.12.2008

vector_toCharArray  [top]

vector_toCharArray ( Pointer, Pointer, Unsigned, Unsigned )
Copies all entries of this vector 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.
Parameters:
Pointer Pointer to the vector
Pointer Pointer to the array
Numeric (Unsigned) (10) Element count
Numeric (Unsigned) (10) Element length
Exported.
Author:
Mihael Schmidt
Date:
23.01.2009

vector_toString  [top]

Character vector_toString ( Pointer, Character, Character, Character )
Returns a string with the vector 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.
Parameters:
Pointer Pointer to the vector
Character (1) separator (default: ,)
Character (100) enclosing character (default: nothing)
Character (100) enclosing character at the end of item (default: nothing)
Return value:
Character (65535) character representation of all vector items
Exported.
Author:
Mihael Schmidt
Date:
26.01.2009