nekokun /NekoKun.Serialization.RubyMarshal/Objects/RubyArray.cs

Language C# Lines 161
MD5 Hash ba1a753ff24391593a5fa878eb11890a Estimated Cost $3,686 (why?)
Repository https://bitbucket.org/nekokun/nekokun.git View Raw File
  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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System;
using System.Collections.Generic;
using System.Text;

namespace NekoKun.Serialization.RubyMarshal
{
    [Serializable]
    [System.Diagnostics.DebuggerDisplay("RubyArray: Count = {Count}")]
    [System.Diagnostics.DebuggerTypeProxy(typeof(RubyArrayDebugView))]
    public class RubyArray : RubyObject, IEnumerable<object>, System.Collections.IEnumerable
    {
        private List<object> list;

        public object this[int index]
        {
            get
            {
                return list[index];
            }
            set
            {
                list[index] = value;
            }
        }

        IEnumerator<object> IEnumerable<object>.GetEnumerator()
        {
            return list.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return list.GetEnumerator();
        }

        public static implicit operator List<object>(RubyArray that)
        {
            return that.list;
        }

        public static implicit operator RubyArray(List<object> that)
        {
            return new RubyArray(that);
        }

        public RubyArray()
        {
            list = new List<object>();
            this.ClassName = RubySymbol.GetSymbol("Array");
        }
        public RubyArray(IEnumerable<object> collection)
        {
            list = new List<object>(collection);
            this.ClassName = RubySymbol.GetSymbol("Array");
        }
        public RubyArray(int capacity)
        {
            list = new List<object>(capacity);
            this.ClassName = RubySymbol.GetSymbol("Array");
        }
        public int Capacity { get { return list.Capacity; } set { list.Capacity = value; } }
        public int Count { get { return list.Count; } }
        public int Size { get { return list.Count; } }
        public int Length { get { return list.Count; } }
        public void Add(object item) { list.Add(item); }
        public void AddRange(IEnumerable<object> collection) { list.AddRange(collection); }
        public System.Collections.ObjectModel.ReadOnlyCollection<object> AsReadOnly() { return list.AsReadOnly(); }
        public int BinarySearch(object item) { return list.BinarySearch(item); }
        public int BinarySearch(object item, IComparer<object> comparer) { return list.BinarySearch(item, comparer); }
        public int BinarySearch(int index, int count, object item, IComparer<object> comparer) { return list.BinarySearch(index, count, item, comparer); }
        public void Clear() { list.Clear(); }
        public bool Contains(object item) { return list.Contains(item); }
        public List<TOutput> ConvertAll<TOutput>(Converter<object, TOutput> converter) { return list.ConvertAll<TOutput>(converter); }
        public void CopyTo(object[] array) { list.CopyTo(array); }
        public void CopyTo(object[] array, int arrayIndex) { list.CopyTo(array, arrayIndex); }
        public void CopyTo(int index, object[] array, int arrayIndex, int count) { list.CopyTo(index, array, arrayIndex, count); }
        public bool Exists(Predicate<object> match) { return list.Exists(match); }
        public object Find(Predicate<object> match) { return list.Find(match); }
        public List<object> FindAll(Predicate<object> match) { return list.FindAll(match); }
        public int FindIndex(Predicate<object> match) { return list.FindIndex(match); }
        public int FindIndex(int startIndex, Predicate<object> match) { return list.FindIndex(startIndex, match); }
        public int FindIndex(int startIndex, int count, Predicate<object> match) { return list.FindIndex(startIndex, count, match); }
        public object FindLast(Predicate<object> match) { return list.FindLast(match); }
        public int FindLastIndex(Predicate<object> match) { return list.FindLastIndex(match); }
        public int FindLastIndex(int startIndex, Predicate<object> match) { return list.FindLastIndex(startIndex, match); }
        public int FindLastIndex(int startIndex, int count, Predicate<object> match) { return list.FindLastIndex(startIndex, count, match); }
        public void ForEach(Action<object> action) { list.ForEach(action); }
        public List<object>.Enumerator GetEnumerator() { return list.GetEnumerator(); }
        public List<object> GetRange(int index, int count) { return list.GetRange(index, count); }
        public int IndexOf(object item) { return list.IndexOf(item); }
        public int IndexOf(object item, int index) { return list.IndexOf(item, index); }
        public int IndexOf(object item, int index, int count) { return list.IndexOf(item, index); }
        public void Insert(int index, object item) { list.Insert(index, item); }
        public void InsertRange(int index, IEnumerable<object> collection) { list.InsertRange(index, collection); }
        public int LastIndexOf(object item) { return list.LastIndexOf(item); }
        public int LastIndexOf(object item, int index) { return list.LastIndexOf(item, index); }
        public int LastIndexOf(object item, int index, int count) { return list.LastIndexOf(item, index, count); }
        public bool Remove(object item) { return list.Remove(item); }
        public int RemoveAll(Predicate<object> match) { return list.RemoveAll(match); }
        public void RemoveAt(int index) { list.RemoveAt(index); }
        public void RemoveRange(int index, int count) { list.RemoveRange(index, count); }
        public void Reverse() { list.Reverse(); }
        public void Reverse(int index, int count) { list.Reverse(index, count); }
        public void Sort() { list.Sort(); }
        public void Sort(Comparison<object> comparison) { list.Sort(comparison); }
        public void Sort(IComparer<object> comparer) { list.Sort(comparer); }
        public void Sort(int index, int count, IComparer<object> comparer) { list.Sort(index, count, comparer); }
        public object[] ToArray() { return list.ToArray(); }
        public void TrimExcess() { list.TrimExcess(); }
        public bool TrueForAll(Predicate<object> match) { return list.TrueForAll(match); }

        public List<TOutput> Map<TOutput>(Converter<object, TOutput> converter) { return list.ConvertAll<TOutput>(converter); }
        public List<TOutput> Collect<TOutput>(Converter<object, TOutput> converter) { return list.ConvertAll<TOutput>(converter); }
        public void Each(Action<object> action) { Array.ForEach<object>(this.ToArray(), action); }
        public void Push(object item) { 
            list.Add(item); 
        }
        public void Push(params object[] items)
        {
            list.AddRange(items);
        }
        public object Pop() {
            object obj = list[list.Count - 1];
            list.RemoveAt(list.Count - 1);
            return obj;
        }
        public object Shift()
        {
            object obj = list[0];
            list.RemoveAt(0);
            return obj;
        }
        public void Unshift(object item)
        {
            list.Insert(0, item);
        }
        public void Unshift(params object[] items)
        {
            list.InsertRange(0, items);
        }

        internal class RubyArrayDebugView
        {
            private RubyArray hashtable;
            public RubyArrayDebugView(RubyArray hashtable)
            {
                this.hashtable = hashtable;
            }

            [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.RootHidden)]
            public object[] Objects
            {
                get
                {
                    return this.hashtable.ToArray();
                }
            }
        }
    }
}
Back to Top