33using System . Collections . Generic ;
44using UnityEngine ;
55
6- public class Collection < T > : BaseCollection , IEnumerable < T >
6+ namespace ScriptableObjectArchitecture
77{
8- public new T this [ int index ]
8+ public class Collection < T > : BaseCollection , IEnumerable < T >
99 {
10- get
10+ public new T this [ int index ]
1111 {
12- return _list [ index ] ;
12+ get
13+ {
14+ return _list [ index ] ;
15+ }
16+ set
17+ {
18+ _list [ index ] = value ;
19+ }
1320 }
14- set
15- {
16- _list [ index ] = value ;
17- }
18- }
1921
20- [ SerializeField ]
21- private List < T > _list = new List < T > ( ) ;
22+ [ SerializeField ]
23+ private List < T > _list = new List < T > ( ) ;
2224
23- public override IList List
24- {
25- get
25+ public override IList List
2626 {
27- return _list ;
27+ get
28+ {
29+ return _list ;
30+ }
2831 }
29- }
30- public override Type Type
31- {
32- get
32+ public override Type Type
3333 {
34- return typeof ( T ) ;
34+ get
35+ {
36+ return typeof ( T ) ;
37+ }
3538 }
36- }
3739
38- public void Add ( T obj )
39- {
40- if ( ! _list . Contains ( obj ) )
41- _list . Add ( obj ) ;
42- }
43- public void Remove ( T obj )
44- {
45- if ( _list . Contains ( obj ) )
46- _list . Remove ( obj ) ;
47- }
48- public void Clear ( )
49- {
50- _list . Clear ( ) ;
51- }
52- public bool Contains ( T value )
53- {
54- return _list . Contains ( value ) ;
55- }
56- public int IndexOf ( T value )
57- {
58- return _list . IndexOf ( value ) ;
59- }
60- public void RemoveAt ( int index )
61- {
62- _list . RemoveAt ( index ) ;
63- }
64- public void Insert ( int index , T value )
65- {
66- _list . Insert ( index , value ) ;
67- }
68- IEnumerator IEnumerable . GetEnumerator ( )
69- {
70- return GetEnumerator ( ) ;
71- }
72- public IEnumerator < T > GetEnumerator ( )
73- {
74- return _list . GetEnumerator ( ) ;
75- }
76- public override string ToString ( )
77- {
78- return "Collection<" + typeof ( T ) + ">(" + Count + ")" ;
79- }
40+ public void Add ( T obj )
41+ {
42+ if ( ! _list . Contains ( obj ) )
43+ _list . Add ( obj ) ;
44+ }
45+ public void Remove ( T obj )
46+ {
47+ if ( _list . Contains ( obj ) )
48+ _list . Remove ( obj ) ;
49+ }
50+ public void Clear ( )
51+ {
52+ _list . Clear ( ) ;
53+ }
54+ public bool Contains ( T value )
55+ {
56+ return _list . Contains ( value ) ;
57+ }
58+ public int IndexOf ( T value )
59+ {
60+ return _list . IndexOf ( value ) ;
61+ }
62+ public void RemoveAt ( int index )
63+ {
64+ _list . RemoveAt ( index ) ;
65+ }
66+ public void Insert ( int index , T value )
67+ {
68+ _list . Insert ( index , value ) ;
69+ }
70+ IEnumerator IEnumerable . GetEnumerator ( )
71+ {
72+ return GetEnumerator ( ) ;
73+ }
74+ public IEnumerator < T > GetEnumerator ( )
75+ {
76+ return _list . GetEnumerator ( ) ;
77+ }
78+ public override string ToString ( )
79+ {
80+ return "Collection<" + typeof ( T ) + ">(" + Count + ")" ;
81+ }
82+ }
8083}
0 commit comments