tangxu
2024-10-22 4d9fe5ed98ceb6b8fe9dc52ebfb80860ad1aee99
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
// COPYRIGHT (C) Tom. ALL RIGHTS RESERVED.
// THE AntdUI PROJECT IS AN WINFORM LIBRARY LICENSED UNDER THE Apache-2.0 License.
// LICENSED UNDER THE Apache License, VERSION 2.0 (THE "License")
// YOU MAY NOT USE THIS FILE EXCEPT IN COMPLIANCE WITH THE License.
// YOU MAY OBTAIN A COPY OF THE LICENSE AT
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE
// DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING PERMISSIONS AND
// LIMITATIONS UNDER THE License.
// GITEE: https://gitee.com/antdui/AntdUI
// GITHUB: https://github.com/AntdUI/AntdUI
// CSDN: https://blog.csdn.net/v_132
// QQ: 17379620
 
using System;
using System.Collections;
using System.Collections.Generic;
 
namespace AntdUI
{
    public class ColumnCollection : IEnumerable<Column>
    {
        List<Column> list;
        public ColumnCollection() { list = new List<Column>(); }
        public ColumnCollection(int count) { list = new List<Column>(count); }
        public ColumnCollection(IEnumerable<Column> collection) { list = new List<Column>(collection); }
 
        public Column this[int index]
        {
            get => list[index];
            set => list[index] = value;
        }
        public Column? this[string key]
        {
            get
            {
                foreach (var item in list)
                {
                    if (item.Key == key) return item;
                }
                return null;
            }
            set
            {
                if (value == null) return;
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].Key == key)
                    {
                        list[i] = value;
                        return;
                    }
                }
            }
        }
 
        #region 原生
 
        #region 列表
 
        public IEnumerator<Column> GetEnumerator() => list.GetEnumerator();
        IEnumerator IEnumerable.GetEnumerator() => list.GetEnumerator();
        public Column[] ToArray() => list.ToArray();
        public void ForEach(Action<Column> action) => list.ForEach(action);
        public bool TrueForAll(Predicate<Column> match) => list.TrueForAll(match);
 
        #endregion
 
        public int Count => list.Count;
 
        #region 添加
 
        public void Add(Column item) => list.Add(item);
        public void AddRange(IEnumerable<Column> collection) => list.AddRange(collection);
 
        public void Insert(int index, Column item) => list.Insert(index, item);
        public void InsertRange(int index, IEnumerable<Column> collection) => list.InsertRange(index, collection);
 
        #endregion
 
        #region 判断/查找
 
        public bool Contains(Column item) => list.Contains(item);
 
        public int IndexOf(Column item) => list.IndexOf(item);
        public int IndexOf(Column item, int index) => list.IndexOf(item, index);
        public int IndexOf(Column item, int index, int count) => list.IndexOf(item, index, count);
 
        public int LastIndexOf(Column item) => list.LastIndexOf(item);
        public int LastIndexOf(Column item, int index) => list.LastIndexOf(item, index);
        public int LastIndexOf(Column item, int index, int count) => list.LastIndexOf(item, index, count);
 
        public bool Exists(Predicate<Column> match) => list.Exists(match);
 
        public Column? Find(Predicate<Column> match) => list.Find(match);
        public List<Column> FindAll(Predicate<Column> match) => list.FindAll(match);
        public int FindIndex(Predicate<Column> match) => list.FindIndex(match);
        public int FindIndex(int startIndex, Predicate<Column> match) => list.FindIndex(startIndex, match);
        public int FindIndex(int startIndex, int count, Predicate<Column> match) => list.FindIndex(startIndex, count, match);
 
        public Column? FindLast(Predicate<Column> match) => list.FindLast(match);
        public int FindLastIndex(Predicate<Column> match) => list.FindLastIndex(match);
        public int FindLastIndex(int startIndex, Predicate<Column> match) => list.FindLastIndex(startIndex, match);
        public int FindLastIndex(int startIndex, int count, Predicate<Column> match) => list.FindLastIndex(startIndex, count, match);
 
        public List<Column> GetRange(int index, int count) => list.GetRange(index, count);
 
        #endregion
 
        #region 删除
 
        public void Clear() => list.Clear();
 
        public bool Remove(Column item) => list.Remove(item);
        public void RemoveAt(int index) => list.RemoveAt(index);
        public int RemoveAll(Predicate<Column> match) => list.RemoveAll(match);
        public void RemoveRange(int index, int count) => list.RemoveRange(index, count);
 
        #endregion
 
        public void Reverse() => list.Reverse();
        public void Reverse(int index, int count) => list.Reverse(index, count);
 
        public void Sort() => list.Sort();
        public void Sort(IComparer<Column> comparer) => list.Sort(comparer);
        public void Sort(Comparison<Column> comparison) => list.Sort(comparison);
        public void Sort(int index, int count, IComparer<Column> comparer) => list.Sort(index, count, comparer);
 
        public void CopyTo(Column[] array) => list.CopyTo(array);
        public void CopyTo(Column[] array, int arrayIndex) => list.CopyTo(array, arrayIndex);
        public void CopyTo(int index, Column[] array, int arrayIndex, int count) => list.CopyTo(index, array, arrayIndex, count);
 
        public int BinarySearch(Column item) => list.BinarySearch(item);
        public int BinarySearch(Column item, IComparer<Column> comparer) => list.BinarySearch(item, comparer);
        public int BinarySearch(int index, int count, Column item, IComparer<Column> comparer) => list.BinarySearch(index, count, item, comparer);
 
        #endregion
    }
}