-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathSvgElementCollection.cs
More file actions
51 lines (44 loc) · 1.37 KB
/
SvgElementCollection.cs
File metadata and controls
51 lines (44 loc) · 1.37 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ST.Library.Drawing.SvgRender
{
public sealed class SvgElementCollection : IEnumerable
{
public int Count { get; private set; }
private SvgElement[] m_arr;
internal SvgElementCollection(int capacity) {
m_arr = new SvgElement[capacity];
}
public SvgElement this[int nIndex] {
get {
if (nIndex < 0 || nIndex >= this.Count) {
throw new ArgumentOutOfRangeException("nIndex");
}
return m_arr[nIndex];
}
}
internal void Add(SvgElement ele) {
this.EnsureSpace(1);
m_arr[this.Count++] = ele;
}
private void EnsureSpace(int nCount) {
if (this.Count + nCount <= m_arr.Length) {
return;
}
SvgElement[] temp = new SvgElement[Math.Max(m_arr.Length << 1, this.Count + nCount)];
m_arr.CopyTo(temp, 0);
m_arr = temp;
}
public IEnumerator<SvgElement> GetEnumerator() {
for (int i = 0; i < this.Count; i++) {
yield return m_arr[i];
}
}
IEnumerator IEnumerable.GetEnumerator() {
return this.GetEnumerator();
}
}
}