BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
BrawlLib.Internal.MemoryList< T > Class Template Reference
Inheritance diagram for BrawlLib.Internal.MemoryList< T >:

Public Member Functions

 MemoryList (void *address, int count)
 
 MemoryList (void *address, int count, bool readOnly)
 
 MemoryList (void *address, int count, int capacity, bool readOnly)
 
int IndexOf (T item)
 
void Insert (int index, T item)
 
void RemoveAt (int index)
 
void Add (T item)
 
void Clear ()
 
bool Contains (T item)
 
void CopyTo (T[] array, int arrayIndex)
 
bool Remove (T item)
 
IEnumerator< T > GetEnumerator ()
 

Properties

this[int index] [get, set]
 
int Count [get]
 
int Capacity [get]
 
bool IsReadOnly [get]
 

Constructor & Destructor Documentation

◆ MemoryList() [1/3]

BrawlLib.Internal.MemoryList< T >.MemoryList ( void *  address,
int  count 
)
inline
48 : this(address, count, count, true)
49 {
50 }

◆ MemoryList() [2/3]

BrawlLib.Internal.MemoryList< T >.MemoryList ( void *  address,
int  count,
bool  readOnly 
)
inline
52 : this(address, count, count, readOnly)
53 {
54 }

◆ MemoryList() [3/3]

BrawlLib.Internal.MemoryList< T >.MemoryList ( void *  address,
int  count,
int  capacity,
bool  readOnly 
)
inline
57 {
58 _count = count;
59 _cap = capacity;
60 _readOnly = readOnly;
61 _stride = Marshal.SizeOf(typeof(T));
62 _base = (byte*) address;
63 }

Member Function Documentation

◆ Add()

void BrawlLib.Internal.MemoryList< T >.Add ( item)
inline
141 {
142 if (_readOnly || _count >= _cap)
143 {
144 throw new AccessViolationException();
145 }
146
147 Marshal.StructureToPtr(item, (IntPtr) (_base + _count * _stride), false);
148 _count++;
149 }

◆ Clear()

void BrawlLib.Internal.MemoryList< T >.Clear ( )
inline
152 {
153 _count = 0;
154 }

◆ Contains()

bool BrawlLib.Internal.MemoryList< T >.Contains ( item)
inline
157 {
158 return IndexOf(item) >= 0;
159 }
int IndexOf(T item)
Definition: MemoryList.cs:65

◆ CopyTo()

void BrawlLib.Internal.MemoryList< T >.CopyTo ( T[]  array,
int  arrayIndex 
)
inline
162 {
163 if (arrayIndex + _count > array.Length)
164 {
165 throw new ArgumentException();
166 }
167
168 int index = arrayIndex;
169 foreach (T t in this)
170 {
171 array[index++] = t;
172 }
173 }

◆ GetEnumerator()

IEnumerator< T > BrawlLib.Internal.MemoryList< T >.GetEnumerator ( )
inline
197 {
198 return new MemoryEnumerator<T>(_base, _count);
199 }

◆ IndexOf()

int BrawlLib.Internal.MemoryList< T >.IndexOf ( item)
inline
66 {
67 byte* p = _base;
68 for (int i = 0; i < _count; i++, p += _stride)
69 {
70 if (item.Equals(Marshal.PtrToStructure((IntPtr) p, typeof(T))))
71 {
72 return i;
73 }
74 }
75
76 return -1;
77 }

◆ Insert()

void BrawlLib.Internal.MemoryList< T >.Insert ( int  index,
item 
)
inline
80 {
81 if (_readOnly || _count >= _cap)
82 {
83 throw new AccessViolationException();
84 }
85
86 if (index >= _count || index < 0)
87 {
88 throw new IndexOutOfRangeException();
89 }
90
91 byte* p = _base + index * _stride;
92 Memory.Move(p + _stride, p, (uint) ((_count - index) * _stride));
93 _count++;
94 }

◆ Remove()

bool BrawlLib.Internal.MemoryList< T >.Remove ( item)
inline
180 {
181 if (_readOnly)
182 {
183 throw new AccessViolationException();
184 }
185
186 int index = IndexOf(item);
187 if (index >= 0)
188 {
189 RemoveAt(index);
190 return true;
191 }
192
193 return false;
194 }
void RemoveAt(int index)
Definition: MemoryList.cs:96

◆ RemoveAt()

void BrawlLib.Internal.MemoryList< T >.RemoveAt ( int  index)
inline
97 {
98 if (_readOnly)
99 {
100 throw new AccessViolationException();
101 }
102
103 if (index >= _count || index < 0)
104 {
105 throw new IndexOutOfRangeException();
106 }
107
108 byte* p = _base + index * _stride;
109 Memory.Move(p, p + _stride, (uint) ((_count - 1 - index) * _stride));
110 _count--;
111 }

Property Documentation

◆ Capacity

int BrawlLib.Internal.MemoryList< T >.Capacity
get

◆ Count

int BrawlLib.Internal.MemoryList< T >.Count
get

◆ IsReadOnly

bool BrawlLib.Internal.MemoryList< T >.IsReadOnly
get

◆ this[int index]

T BrawlLib.Internal.MemoryList< T >.this[int index]
getset
114 {
115 get
116 {
117 if (index >= _count || index < 0)
118 {
119 throw new IndexOutOfRangeException();
120 }
121
122 return (T) Marshal.PtrToStructure((IntPtr) (_base + index * _stride), typeof(T));
123 }
124 set
125 {
126 if (_readOnly)
127 {
128 throw new AccessViolationException();
129 }
130
131 if (index >= _count || index < 0)
132 {
133 throw new IndexOutOfRangeException();
134 }
135
136 Marshal.StructureToPtr(value, (IntPtr) (_base + index * _stride), false);
137 }
138 }

The documentation for this class was generated from the following file: