Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ExpressionList.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections;
5 using System.Collections.Generic;
6 
7 namespace SiliconStudio.Shaders.Ast
8 {
9  /// <summary>
10  /// A list of expression.
11  /// </summary>
12  public class ExpressionList : Expression, IList<Expression>
13  {
14  /// <summary>
15  /// Initializes a new instance of the <see cref="ExpressionList"/> class.
16  /// </summary>
17  public ExpressionList()
18  {
19  Expressions = new List<Expression>();
20  }
21 
22  /// <summary>
23  /// Initializes a new instance of the <see cref="ExpressionList"/> class.
24  /// </summary>
25  /// <param name="expressions">The expressions.</param>
26  public ExpressionList(params Expression [] expressions)
27  {
28  Expressions = new List<Expression>();
29  if (expressions != null)
30  Expressions.AddRange(expressions);
31  }
32 
33  /// <inheritdoc/>
34  public int Count
35  {
36  get
37  {
38  return Expressions.Count;
39  }
40  }
41 
42  /// <inheritdoc/>
43  public bool IsReadOnly
44  {
45  get
46  {
47  return false;
48  }
49  }
50 
51  /// <summary>
52  /// Gets or sets the expressions.
53  /// </summary>
54  /// <value>
55  /// The expressions.
56  /// </value>
57  public List<Expression> Expressions { get; set; }
58 
59  /// <summary>
60  /// Adds a collection to this instance.
61  /// </summary>
62  /// <param name="collection">The collection to add to this instance.</param>
63  public void AddRange(IEnumerable<Expression> collection)
64  {
65  Expressions.AddRange(collection);
66  }
67 
68  /// <summary>
69  /// Gets a subset of this instance
70  /// </summary>
71  /// <param name="index">The index.</param>
72  /// <param name="count">The count.</param>
73  /// <returns>A subset of this instance</returns>
74  public List<Expression> GetRange(int index, int count)
75  {
76  return Expressions.GetRange(index, count);
77  }
78 
79  /// <summary>
80  /// Inserts a collection at the specified index.
81  /// </summary>
82  /// <param name="index">The index.</param>
83  /// <param name="collection">The collection.</param>
84  public void InsertRange(int index, IEnumerable<Expression> collection)
85  {
86  Expressions.InsertRange(index, collection);
87  }
88 
89  /// <summary>
90  /// Removes a range of elements.
91  /// </summary>
92  /// <param name="index">The index.</param>
93  /// <param name="count">The count.</param>
94  public void RemoveRange(int index, int count)
95  {
96  Expressions.RemoveRange(index, count);
97  }
98 
99  /// <summary>
100  /// Removes all elements with a predicate function.
101  /// </summary>
102  /// <param name="match">The match.</param>
103  /// <returns>Number of elements removed</returns>
104  public int RemoveAll(Predicate<Expression> match)
105  {
106  return Expressions.RemoveAll(match);
107  }
108 
109  /// <inheritdoc/>
110  public Expression this[int index]
111  {
112  get
113  {
114  return Expressions[index];
115  }
116 
117  set
118  {
119  Expressions[index] = value;
120  }
121  }
122 
123  /// <inheritdoc/>
124  public void Add(Expression item)
125  {
126  Expressions.Add(item);
127  }
128 
129  public override IEnumerable<Node> Childrens()
130  {
131  return this;
132  }
133 
134  /// <inheritdoc/>
135  public void Clear()
136  {
137  Expressions.Clear();
138  }
139 
140  /// <inheritdoc/>
141  public bool Contains(Expression item)
142  {
143  return Expressions.Contains(item);
144  }
145 
146  /// <inheritdoc/>
147  public void CopyTo(Expression[] array, int arrayIndex)
148  {
149  Expressions.CopyTo(array, arrayIndex);
150  }
151 
152  /// <inheritdoc/>
153  public IEnumerator<Expression> GetEnumerator()
154  {
155  return Expressions.GetEnumerator();
156  }
157 
158  /// <inheritdoc/>
159  public int IndexOf(Expression item)
160  {
161  return Expressions.IndexOf(item);
162  }
163 
164  /// <inheritdoc/>
165  public void Insert(int index, Expression item)
166  {
167  Expressions.Insert(index, item);
168  }
169 
170  /// <inheritdoc/>
171  public bool Remove(Expression item)
172  {
173  return Expressions.Remove(item);
174  }
175 
176  /// <inheritdoc/>
177  public void RemoveAt(int index)
178  {
179  Expressions.RemoveAt(index);
180  }
181 
182  /// <inheritdoc/>
183  IEnumerator IEnumerable.GetEnumerator()
184  {
185  return GetEnumerator();
186  }
187 
188  public override string ToString()
189  {
190  return string.Join(", ", this);
191  }
192  }
193 }
void AddRange(IEnumerable< Expression > collection)
Adds a collection to this instance.
ExpressionList()
Initializes a new instance of the ExpressionList class.
List< Expression > GetRange(int index, int count)
Gets a subset of this instance
void CopyTo(Expression[] array, int arrayIndex)
int RemoveAll(Predicate< Expression > match)
Removes all elements with a predicate function.
_In_ size_t count
Definition: DirectXTexP.h:174
IEnumerator< Expression > GetEnumerator()
void RemoveRange(int index, int count)
Removes a range of elements.
void Insert(int index, Expression item)
void InsertRange(int index, IEnumerable< Expression > collection)
Inserts a collection at the specified index.
override IEnumerable< Node > Childrens()
Gets the child nodes.
ExpressionList(params Expression[] expressions)
Initializes a new instance of the ExpressionList class.