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