Merged into single file, added assertions
[mono.git] / mcs / class / System.Core / System.Linq.Parallel / AggregationList.cs
1 //
2 // AggregationList.cs
3 //
4 // Author:
5 //       Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
6 //
7 // Copyright (c) 2010 Jérémie "Garuma" Laval
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26
27 #if NET_4_0
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31
32 namespace System.Linq.Parallel
33 {
34         internal class AggregationList<T> : IList<T>
35         {
36                 readonly IList<IList<T>> listes;
37                 readonly int count;
38
39                 internal AggregationList (IList<IList<T>> listes)
40                 {
41                         this.listes = listes;
42                         foreach (var l in listes)
43                                 count += l.Count;
44                 }
45
46                 public int IndexOf (T item)
47                 {
48                         throw new NotImplementedException();
49                 }
50
51                 public void Insert (int index, T item)
52                 {
53                         throw new NotImplementedException();
54                 }
55
56                 public void RemoveAt (int index)
57                 {
58                         throw new NotImplementedException();
59                 }
60
61                 public T this[int index] {
62                         get {
63                                 int listIndex, newIndex;
64                                 GetModifiedIndexes (index, out listIndex, out newIndex);
65
66                                 return listes[listIndex][newIndex];
67                         }
68                         set {
69                                 throw new NotImplementedException();
70                         }
71                 }
72
73                 void GetModifiedIndexes (int index, out int listIndex, out int newIndex)
74                 {
75                         listIndex = 0;
76                         newIndex = index;
77
78                         while (newIndex >= listes[listIndex].Count) {
79                                 newIndex -= listes[listIndex].Count;
80                                 listIndex++;
81
82                                 if (listIndex > listes.Count)
83                                         throw new ArgumentOutOfRangeException ();
84                         }
85                 }
86
87                 public void Add (T item)
88                 {
89                         throw new NotImplementedException();
90                 }
91
92                 public void Clear ()
93                 {
94                         throw new NotImplementedException();
95                 }
96
97                 public bool Contains (T item)
98                 {
99                         throw new NotImplementedException();
100                 }
101
102                 public void CopyTo (T[] array, int arrayIndex)
103                 {
104                         throw new NotImplementedException();
105                 }
106
107                 public bool Remove (T item)
108                 {
109                         throw new NotImplementedException();
110                 }
111
112                 public int Count {
113                         get {
114                                 return count;
115                         }
116                 }
117
118                 public bool IsReadOnly {
119                         get {
120                                 return true;
121                         }
122                 }
123
124                 IEnumerator<T> IEnumerable<T>.GetEnumerator ()
125                 {
126                         return null;
127                 }
128
129                 IEnumerator IEnumerable.GetEnumerator ()
130                 {
131                         return null;
132                 }
133         }
134 }
135 #endif