forked from emojicode/emojicode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmojicodeList.h
64 lines (51 loc) · 1.43 KB
/
EmojicodeList.h
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
//
// List.h
// Emojicode
//
// Created by Theo Weidmann on 18.01.15.
// Copyright (c) 2015 Theo Weidmann. All rights reserved.
//
#ifndef EmojicodeList_h
#define EmojicodeList_h
#include "EmojicodeAPI.h"
struct List {
/** The number of elements in the list. */
size_t count;
/** The capacity of the list. */
size_t capacity;
/**
* The array which stores the list items which has a size of @c capacity * sizeof(Something).
* Can be @c NULL if @c capacity is 0.
*/
Object *items;
};
/**
* Inserts @c o at the end of the list. O(1)
* @warning GC-invoking
*/
void listAppend(Object *lo, Something o, Thread *thread);
/** Removes the last element of the list and returns it. O(1) */
Something listPop(List *list);
/**
* Returns the item at @c i or @c NULL if @c i is out of bounds.
*/
Something listGet(List *list, EmojicodeInteger i);
/**
* Creates a list by copying all references from @c cpdList.
*/
Object* listFromList(List *cpdList);
/**
* Removes the first occourence of x.
*/
bool listRemove(List *list, Something x);
/**
* Shuffles the list in place by using the Fisher Yates alogrithm.
*/
void listShuffleInPlace(List *list);
/** Releases list @c l */
void listRelease(void *l);
/** List marker for the GC */
void listMark(Object *self);
MethodHandler listMethodForName(EmojicodeChar method);
InitializerHandler listInitializerForName(EmojicodeChar method);
#endif /* EmojicodeList_h */