forked from idea-iitd/RISC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayListInt.h
More file actions
58 lines (48 loc) · 2.1 KB
/
Copy patharrayListInt.h
File metadata and controls
58 lines (48 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* arrayListInt.h
*
* Created on: 01-Dec-2018
* Author: jithin
*/
#ifndef ARRAYLISTINT_H_
#define ARRAYLISTINT_H_
#include "global.h"
#include "helper.h"
struct _array_list_bucket {
u_long *data;
int size;
struct _array_list_bucket *next;
struct _array_list_bucket *prev;
};
typedef struct {
u_long size; //number of elements
unsigned int bucketMaxLen;
struct _array_list_bucket *head;
struct _array_list_bucket *tail;
}arrayListtype;
typedef struct {
int nextIndex; //current index
unsigned int _numBucketsBefore; // number of buckets before this
u_long nextAvailable; //number of more elements available
struct _array_list_bucket *bucket;
int bucketMaxLen;
}arrayList_Iterator_type;
arrayListtype* new_arrayListtype (unsigned int bucketMaxLen);
u_long arrayList_get (arrayListtype *arr, u_long index);
void arrayList_put (arrayListtype *arr, u_long val);
void arrayList_iterateAndWork (arrayListtype *arr, u_long startIndex, u_long endIndex, void (*worker) (u_long));
void arrayList_iterateAndWork_2 (arrayListtype *arr, u_long startIndex, u_long endIndex, void (*worker) (int*, int), int *dest);
void arrayList_iterateAndWork_3 (arrayListtype *arr, u_long startIndex, u_long endIndex, int *dest);
void free_arrayListtype(arrayListtype *arr);
void arrayList_IteratorMoveTo (arrayList_Iterator_type *iterator, u_long val);
void arrayList_IteratorMoveTo_Binary(arrayList_Iterator_type *iterator, u_long val);
int arrayList_IteratorFind (arrayList_Iterator_type *iterator, u_long val, int *found);
u_long arrayList_IteratorFind_Binary(arrayList_Iterator_type *iterator, u_long val, int *found);
//iterator
arrayList_Iterator_type* arrayList_getIterator (arrayListtype *arr);
arrayList_Iterator_type* arrayList_getIterator_2 (arrayListtype *arr, int startindex);
struct _array_list_bucket* arrayList_getBucket (arrayListtype *arr, int startIndex);
u_long arrayList_IteratorGetNext (arrayList_Iterator_type *iterator);
void arrayList_IteratorFree (arrayList_Iterator_type *iterator);
void arrayList_resetIterator (arrayList_Iterator_type *iterator, arrayListtype *arr);
#endif /* ARRAYLISTINT_H_ */