Repository navigation
Expand file tree
/
Copy pathArrayList.h
More file actions
145 lines (119 loc) · 2.9 KB
/
Copy pathArrayList.h
File metadata and controls
145 lines (119 loc) · 2.9 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef _INCLUDED_SYSTEM_ARRAYLIST_H_
#define _INCLUDED_SYSTEM_ARRAYLIST_H_
#include <vector>
#include "System/String.h"
#include "System/Object.h"
#include "System/Collections/Generic.h"
#include "OS.h"
#include "pragmas.h"
namespace System
{
namespace Collections
{
/// Array class
class ArrayList : public ICollection
{
std::vector<Object> m_vec;
public:
/// Constructor
ArrayList()
{
}
/// get the length of the array
int Length() const
{
return static_cast<int>(m_vec.size());
}
/// get the nth item from the array
const Object& operator[](int index) const
{
return m_vec[index];
}
/// add an item into the array
void Add(const Object& item)
{
m_vec.push_back(item);
}
/// add a range of objects into the array
void AddRange(const List<Object>& c)
{
for(int i=0;i<c.Count();i++){
Add(c[i]);
}
}
/// add a range of objects into the array
void AddRange(const List<String>& c)
{
for(int i=0;i<c.Count();i++){
Add(c[i]);
}
}
// Removes all elements from the ArrayList
void Clear()
{
m_vec.clear();
}
/// Creates a shallow copy of the ArrayList
ArrayList Clone()
{
ArrayList copy;
for(size_t i=0;i<m_vec.size();i++)
{
copy.Add(m_vec[i]);
}
return copy;
}
// Trim the capacity to the number of items
void TrimToSize()
{
// no real implementation needed here yet
}
void Reverse()
{
}
void Sort()
{
}
void SetRange(int index,const ICollection& c)
{
static_cast<void>(index);
static_cast<void>(c);
}
void RemoveRange(int index,int count)
{
static_cast<void>(index);
static_cast<void>(count);
}
void RemoteAt(int index)
{
static_cast<void>(index);
}
void Remove(const Object &obj)
{
static_cast<void>(obj);
}
int IndexOf(const Object &obj)
{
static_cast<void>(obj);
return -1;
}
bool Contains(const Object& obj)
{
static_cast<void>(obj);
return false;
}
void Insert(int index,const Object &obj)
{
static_cast<void>(obj);
}
void InsertRange(int index,const ICollection &c)
{
static_cast<void>(index);
static_cast<void>(c);
}
};
}
}
using namespace System;
using namespace System::Collections;
#endif