-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.h
65 lines (50 loc) · 1.59 KB
/
array.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
65
#pragma once
#include "object.h"
#include <string.h>
#include "string.h"
class Array: public Object {
public:
size_t arraySize;
Object** elements;
/** Constructor for Array **/
Array() {
arraySize = 0;
elements = nullptr;
}
// Appends e to end of array
void push_back(Object* e) {}
// Inserts e at index i
void add(size_t i, Object* e) {}
// Adds elements in c to end of this array
void concat(Array* c) {}
// Inserts all of elements in c into this array at index i
void add_all(size_t i, Array* c) {}
// Removes all of elements from this array
void clear() {
/** assign all the elements to nullptr but maintain the list size **/
}
// Compares o with this array for equality.
bool equals(Object* o) {
/** cast Object* o to Array and check if each element in this Array matches elements in o **/
}
// Returns the element at index
Object* get(size_t index) {}
// Returns the hash code value for this array.
size_t hash() {
/** calculates the hash code and returns the hash code **/
}
// Returns the index of the first occurrence of o, or number greater than size() if not there
size_t index_of(Object* o) {}
//Removes the element at index i
Object* remove(size_t i) {}
// Replaces the element at index i with e
Object* set(size_t i, Object* e) {}
// Return the number of elements in the array
size_t length() {
/** return the arraySize **/
}
//destructing an Array
~Array() {
delete[] elements;
}
};