summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/darray.h29
-rw-r--r--include/hashtable.h13
-rw-r--r--include/nonport.h16
-rw-r--r--include/qsort.h15
4 files changed, 59 insertions, 14 deletions
diff --git a/include/darray.h b/include/darray.h
index f20cb82..5c7c170 100644
--- a/include/darray.h
+++ b/include/darray.h
@@ -5,18 +5,33 @@
extern "C" {
#endif
+typedef s32 (*CompareFunction)(const void *, const void *);
+typedef BOOL (*MapFunction)(const void *, s32);
+typedef void (*DtorFunction)(void *);
+
typedef struct DArray {
s32 size;
- s32 unk4;
- u32 elementSz;
- s32 unkC;
- s32 unk10;
+ s32 capacity;
+ u32 elemSz;
+ s32 growAmount;
+ DtorFunction elemDtor;
char *buf;
} DArray;
-void *ArrayNew(s32 p1, s32 p3, s32 p6);
-void *ArrayNth(DArray *p1, s32 p2);
-void *ArrayMapBackwards2(DArray *p1, s32 p2, s32 p3);
+DArray *ArrayNew(u32 elemSz, s32 initialCap, DtorFunction dtor);
+void ArrayFree(DArray *d);
+s32 ArrayLength(DArray *d);
+void *ArrayNth(DArray *d, s32 n);
+void ArrayAppend(DArray *d, void *elem);
+void ArrayInsertSorted(DArray *d, void *elem, CompareFunction compar);
+void ArrayRemoveAt(DArray *d, s32 n);
+void ArrayDeleteAt(DArray *d, s32 n);
+void ArrayReplaceAt(DArray *d, void *elem, s32 n);
+void ArraySort(DArray *d, CompareFunction compar);
+s32 ArraySearch(DArray *d, void *elem, CompareFunction cmp, s32 start, s32 doBinarySearch);
+void ArrayMapBackwards(DArray *d, MapFunction map, s32 p3);
+void *ArrayMapBackwards2(DArray *d, MapFunction map, s32 p3);
+void ArrayClear(DArray *d);
#ifdef __cplusplus
}
diff --git a/include/hashtable.h b/include/hashtable.h
index 0502273..784ab35 100644
--- a/include/hashtable.h
+++ b/include/hashtable.h
@@ -9,24 +9,23 @@ extern "C" {
typedef s32 (*HashFunction)(void *, s32);
-
typedef struct HashTable {
DArray **chains;
s32 size;
- s32 unk8;
+ DtorFunction dtor;
HashFunction hashFunc;
- s32 unk10; // comparison callback?
+ CompareFunction compar;
} HashTable;
-HashTable *TableNew(s32 p1, s32 p2, HashFunction hf, s32 p4, s32 p5);
-HashTable *TableNew2(s32 p1, s32 size, s32 p3, HashFunction hf, s32 p5, s32 p6);
+HashTable *TableNew(u32 p1, s32 p2, HashFunction hf, CompareFunction cmp, DtorFunction dtor);
+HashTable *TableNew2(u32 p1, s32 size, s32 p3, HashFunction hf, CompareFunction cmp, DtorFunction dtor);
void TableFree(HashTable *table);
s32 TableCount(HashTable *table);
void TableEnter(HashTable *table, void *elem);
BOOL TableRemove(HashTable *table, void *elem);
void *TableLookup(HashTable *table, void *elem);
-void TableMapSafe(HashTable *table, s32 p2, s32 p3);
-void *TableMapSafe2(HashTable *table, s32 p2, s32 p3);
+void TableMapSafe(HashTable *table, MapFunction p2, s32 p3);
+void *TableMapSafe2(HashTable *table, MapFunction p2, s32 p3);
#ifdef __cplusplus
}
diff --git a/include/nonport.h b/include/nonport.h
new file mode 100644
index 0000000..c1ed0e7
--- /dev/null
+++ b/include/nonport.h
@@ -0,0 +1,16 @@
+#ifndef POKEREVO_NONPORT_H
+#define POKEREVO_NONPORT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *gsimalloc(u32 sz);
+void *gsirealloc(void *ptr, u32 sz);
+void gsifree(void *ptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //POKEREVO_NONPORT_H
diff --git a/include/qsort.h b/include/qsort.h
new file mode 100644
index 0000000..c13ae0e
--- /dev/null
+++ b/include/qsort.h
@@ -0,0 +1,15 @@
+#ifndef POKEREVO_QSORT_H
+#define POKEREVO_QSORT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void qsort(void *base, u32 nmemb, u32 size,
+ s32 (*compar)(const void *, const void *));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //POKEREVO_QSORT_H