|
My library
Library for common tasks
|
Functions for working with ArrayList type. More...
#include "types.h"

Go to the source code of this file.
Functions | |
| ArrayList | newAL (const spec_t spec) |
| Allocate a new ArrayList of specified type. More... | |
| ArrayList | newALFromAL (const ArrayList list) |
| Get a copy of an ArrayList. More... | |
| void | appendToAL (ArrayList list,...) |
| Insert an item at the end of an ArrayList. More... | |
| void | insertToAL (ArrayList list, unsigned int index,...) |
| Insert an item at a specified position of an ArrayList. More... | |
| void | setALItem (ArrayList list, unsigned int index,...) |
| Set value of an item of an ArrayList. More... | |
| void | mergeAL (ArrayList list1, const ArrayList list2) |
| Merge two ArrayList. More... | |
| void | sliceAL (ArrayList list, unsigned int begin, unsigned int end) |
| Slice an ArrayList. More... | |
| void | printAL (const spec_t spec, const ArrayList list) |
| Print contents from an ArrayList. More... | |
| void | removeFromAL (ArrayList list, unsigned int index) |
| Remove an item from an ArrayList. More... | |
| void | getFromAL (const ArrayList list, unsigned int index, void *dest) |
| Get an item from an ArrayList. More... | |
| void | deleteAL (ArrayList list,...) |
| Delete an ArrayList. More... | |
| byte | areALEqual (const ArrayList list1, const ArrayList list2,...) |
| Compare two ArrayList. More... | |
| void | reverseAL (ArrayList list) |
| Reverse an ArrayList. More... | |
| void | bubbleSortAL (ArrayList list,...) |
| Bubble sort for ArrayList. More... | |
| void | quickSortAL (ArrayList list,...) |
| Quicksort for ArrayList. More... | |
| byte | isInAL (ArrayList list,...) |
| Detect if an item is inside an ArrayList. More... | |
| int | linearSearchAL (ArrayList list,...) |
| Linear search for ArrayList. More... | |
| ArrayList | chooseNewALFromArray (const spec_t spec, const void *list, unsigned int size) |
| Create an ArrayList from a static array. More... | |
| ArrayList | newALFromCharArray (const char list[], unsigned int size) |
| Create ArrayList from a list of chars. More... | |
| ArrayList | newALFromByteArray (const char list[], unsigned int size) |
| Create ArrayList from a list of bytes. More... | |
| ArrayList | newALFromIntArray (const int list[], unsigned int size) |
| Create ArrayList from a list of ints. More... | |
| ArrayList | newALFromFloatArray (const float list[], unsigned int size) |
| Create ArrayList from a list of floats. More... | |
| ArrayList | newALFromDoubleArray (const double list[], unsigned int size) |
| Create ArrayList from an list of doubles. More... | |
| ArrayList | newALFromPtrArray (const void *list, unsigned int size) |
| Create ArrayList from an list of pointers. More... | |
| unsigned int | getALLength (const ArrayList list) |
| Get the size of an ArrayList. More... | |
| byte | isALEmpty (ArrayList list) |
| Check if ArrayList is empty. More... | |
Functions for working with ArrayList type.
| void appendToAL | ( | ArrayList | list, |
| ... | |||
| ) |
Insert an item at the end of an ArrayList.
| list | The ArrayList you want to append an item to |
| ... | The item you want to append to list |
list. If you don't specify any item to be appended, still no errors occur but the content of your ArrayList can be messed up Compare two ArrayList.
| list1 | The first ArrayList you want to compare |
| list2 | The second ArrayList you want to compare |
| ... | The comparison function needed to compare items inside given lists. This parameter is necessary only for pointer ArrayList type and is ignored otherwise. Must be a function that takes two pointers as argument and returns a positive int if the item pointed by the first argument is greater than the item pointed by the second argument, a negative int if the item pointed by the first argument is is smaller than the item pointed by second, a zero int if the item pointed by first and second arguments are equal |
| TRUE | list1 and list2 have equal type, equal length and equal contents |
| FALSE | list1 and list2 do not have equal type, equal length or equal contents |
| void bubbleSortAL | ( | ArrayList | list, |
| ... | |||
| ) |
Bubble sort for ArrayList.
| list | The ArrayList you want to bubble sort |
| ... | The comparison function needed to compare items inside given lists. This parameter is necessary only for pointer ArrayList type and is ignored otherwise. Must be a function that takes two pointers as argument and returns a positive int if the item pointed by the first argument is greater than the item pointed by the second argument, a negative int if the item pointed by the first argument is is smaller than the item pointed by second, a zero int if the item pointed by first and second arguments are equal |
Create an ArrayList from a static array.
| spec | The type specifier of the array passed. Refer to spec_t |
| list | The list you want to create the ArrayList from |
| size | The number of items in list |
list in the same order | void deleteAL | ( | ArrayList | list, |
| ... | |||
| ) |
Delete an ArrayList.
| list | The ArrayList you want to delete |
| ... | The function used to free memory pointed by every pointer of the ArrayList. Must be a function that takes a pointer as argument. Necessary only for pointer ArrayList type, ignored otherwise. When deleting a pointer ArrayList type if no free function is passed no compiler errors are thrown but you may cause severe memory leaks |
| unsigned int getALLength | ( | const ArrayList | list | ) |
| void getFromAL | ( | const ArrayList | list, |
| unsigned int | index, | ||
| void * | dest | ||
| ) |
| void insertToAL | ( | ArrayList | list, |
| unsigned int | index, | ||
| ... | |||
| ) |
Insert an item at a specified position of an ArrayList.
| list | The ArrayList you want to insert an item into |
| index | The position you want to insert an item at |
| ... | The item you want to insert into list |
list. If you don't specify any item to be inserted, still no errors occur but the content of your ArrayList can be messed up Detect if an item is inside an ArrayList.
| list | The ArrayList you want search in |
| ... | The item you want to search. If searaching in a pointer ArrayList type, after the item you want so search, you must provide the comparison function needed to compare the item you want to search and the items in the ArrayList. Must be a function that takes two pointers as argument and returns a zero int only if the item pointed by first and second arguments are equal |
| TRUE | Given item is contained in list |
| FALSE | Given item is not contained in list |
| int linearSearchAL | ( | ArrayList | list, |
| ... | |||
| ) |
Linear search for ArrayList.
| list | The ArrayList to be inspected |
| ... | The key to be searched. If searaching in a pointer ArrayList type, after the item you want so search, you must provide the comparison function needed to compare the item you want to search and the items in the ArrayList. Must be a function that takes two pointers as argument and returns a zero int only if the item pointed by first and second arguments are equal |
| KEY_NOT_FOUND | The key was not found |
| ArrayList newALFromByteArray | ( | const char | list[], |
| unsigned int | size | ||
| ) |
Create ArrayList from a list of bytes.
Alias for newALFromCharArray(). Used to create ArrayList from byte list. Refer to newALFromCharArray()
| ArrayList newALFromCharArray | ( | const char | list[], |
| unsigned int | size | ||
| ) |
Create ArrayList from a list of chars.
Equivalent to chooseNewALFromArray("%c", list, size). Refer to chooseNewALFromArray()
| ArrayList newALFromDoubleArray | ( | const double | list[], |
| unsigned int | size | ||
| ) |
Create ArrayList from an list of doubles.
Equivalent to chooseNewALFromArray("%lf", list, size). Refer to chooseNewALFromArray()
| ArrayList newALFromFloatArray | ( | const float | list[], |
| unsigned int | size | ||
| ) |
Create ArrayList from a list of floats.
Equivalent to chooseNewALFromArray("%f", list, size). Refer to chooseNewALFromArray()
| ArrayList newALFromIntArray | ( | const int | list[], |
| unsigned int | size | ||
| ) |
Create ArrayList from a list of ints.
Equivalent to chooseNewALFromArray("%i", list, size). Refer to chooseNewALFromArray()
| ArrayList newALFromPtrArray | ( | const void * | list, |
| unsigned int | size | ||
| ) |
Create ArrayList from an list of pointers.
Equivalent to chooseNewALFromArray("%p", list, size). Refer to chooseNewALFromArray()
| void quickSortAL | ( | ArrayList | list, |
| ... | |||
| ) |
Quicksort for ArrayList.
| list | The ArrayList you want to quicksort |
| ... | The comparison function needed to compare items inside given lists. This parameter is necessary only for pointer ArrayList type and is ignored otherwise. Must be a function that takes two pointers as argument and returns a positive int if the item pointed by the first argument is greater than the item pointed by the second argument, a negative int if the item pointed by the first argument is is smaller than the item pointed by second, a zero int if the item pointed by first and second arguments are equal |
| void removeFromAL | ( | ArrayList | list, |
| unsigned int | index | ||
| ) |
| void reverseAL | ( | ArrayList | list | ) |
| void setALItem | ( | ArrayList | list, |
| unsigned int | index, | ||
| ... | |||
| ) |
Set value of an item of an ArrayList.
| list | The ArrayList you want to edit |
| index | The index of the item you want to change |
| ... | The item you want to set the index-th item of list to |