-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathooarray.h
More file actions
97 lines (76 loc) · 2.35 KB
/
Copy pathooarray.h
File metadata and controls
97 lines (76 loc) · 2.35 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Copyright (c) 2011 by Dmitri Dmitriev
* All rights reserved.
*
* This file is part of the OOmnik Conceptual Processor,
* and as such it is subject to the license stated
* in the LICENSE file which you have received
* as part of this distribution.
*
* Project homepage:
* <http://www.oomnik.ru>
*
* Initial author and maintainer:
* Dmitri Dmitriev aka M0nsteR <dmitri@globbie.net>
*
* Code contributors:
* * Jenia Krylov <info@e-krylov.ru>
*
* ---------
* ooarray.h
* OOmnik Dynamic Array
*/
#ifndef OOARRAY_H
#define OOARRAY_H
#include "ooconfig.h"
typedef struct ooArray
{
/******** public attributes ********/
/* constructor */
int (*init)(struct ooArray *self);
/* destructor */
int (*del)(struct ooArray *self);
/* add a value at specific position */
int (*add)(struct ooArray *self,
void *val,
size_t pos);
/* add a value to the end of the array */
int (*push)(struct ooArray *self,
void *val);
/* delete an item */
int (*remove)(struct ooArray *self,
size_t pos);
/* return and delete the last value */
int (*pop)(struct ooArray *self);
/* set the item of the array (check the position) */
int (*set_item)(struct ooArray *self,
void *data,
size_t pos);
/* get the element of array (check the position) */
void* (*get_item)(struct ooArray *self,
size_t pos);
/* delete all items */
void (*clear)(struct ooArray *self);
/* returns the subarray (copy the part of the array) */
struct ooArray* (*get_subsequence)(struct ooArray *self,
size_t start,
size_t length);
/* set the new size */
int (*resize)(struct ooArray *self,
size_t new_size);
/* sort the array */
void (*sort)(struct ooArray *self,
oo_compar_func function);
/* find the element */
void* (*find)(struct ooArray *self,
void *data,
oo_compar_func function);
/******** private attributes ********/
/* pointers to the data */
void **data;
/* array size */
size_t size;
} ooArray;
/* array constructor */
int ooArray_new(struct ooArray **self);
#endif /* OOARRAY_H */