-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathCsvRowCollection.cs
More file actions
103 lines (97 loc) · 3.16 KB
/
CsvRowCollection.cs
File metadata and controls
103 lines (97 loc) · 3.16 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
using System.Collections;
namespace BytecodeApi.CsvParser;
/// <summary>
/// Represents a collection of <see cref="CsvRow" /> objects.
/// </summary>
public sealed class CsvRowCollection : ICollection<CsvRow>
{
private readonly List<CsvRow> Rows;
/// <summary>
/// Gets the <see cref="CsvRow" /> at the specified index.
/// </summary>
/// <param name="index">The index at which to retrieve the <see cref="CsvRow" />.</param>
public CsvRow this[int index]
{
get
{
Check.IndexOutOfRange(index, Count);
return Rows[index];
}
}
/// <summary>
/// Gets the number of rows in this <see cref="CsvRowCollection" />.
/// </summary>
public int Count => Rows.Count;
/// <summary>
/// Gets a value indicating whether the <see cref="CsvRowCollection" /> is read-only.
/// </summary>
public bool IsReadOnly => false;
/// <summary>
/// Initializes a new instance of the <see cref="CsvRowCollection" /> class.
/// </summary>
public CsvRowCollection()
{
Rows = [];
}
/// <summary>
/// Adds a <see cref="CsvRow" /> to the end of the <see cref="CsvRowCollection" />.
/// </summary>
/// <param name="item">The <see cref="CsvRow" /> to be added to the end of the <see cref="CsvRowCollection" />.</param>
public void Add(CsvRow item)
{
Check.ArgumentNull(item);
Rows.Add(item);
}
/// <summary>
/// Removes the first occurrence of a specific <see cref="CsvRow" /> from the <see cref="CsvRowCollection" />.
/// </summary>
/// <param name="item">The <see cref="CsvRow" /> to remove from the <see cref="CsvRowCollection" />.</param>
/// <returns>
/// <see langword="true" />, if <paramref name="item" /> is successfully removed;
/// otherwise, <see langword="false" />.
/// This method also returns <see langword="false" />, if <paramref name="item" /> was not found in the <see cref="CsvRowCollection" />.
/// </returns>
public bool Remove(CsvRow item)
{
return Rows.Remove(item);
}
/// <summary>
/// Removes all elements from the <see cref="CsvRowCollection" />.
/// </summary>
public void Clear()
{
Rows.Clear();
}
/// <summary>
/// Determines whether an element is in the <see cref="CsvRowCollection" />.
/// </summary>
/// <param name="item">The <see cref="CsvRow" /> to locate in the <see cref="CsvRowCollection" />.</param>
/// <returns>
/// <see langword="true" />, if <paramref name="item" /> is found in the <see cref="CsvRowCollection" />;
/// otherwise, <see langword="false" />.
/// </returns>
public bool Contains(CsvRow item)
{
return Rows.Contains(item);
}
void ICollection<CsvRow>.CopyTo(CsvRow[] array, int arrayIndex)
{
Check.ArgumentNull(array);
Check.IndexOutOfRange(arrayIndex, array.Length - Count + 1);
Rows.CopyTo(array, arrayIndex);
}
/// <summary>
/// Returns an enumerator that iterates through the <see cref="CsvRowCollection" />.
/// </summary>
/// <returns>
/// An enumerator that can be used to iterate through the <see cref="CsvRowCollection" />.
/// </returns>
public IEnumerator<CsvRow> GetEnumerator()
{
return Rows.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return Rows.GetEnumerator();
}
}