Lean  $LEAN_TAG$
IReadOnlyWindow.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System.Collections.Generic;
17 
19 {
20  /// <summary>
21  /// Interface type used to pass windows around without worry of external modification
22  /// </summary>
23  /// <typeparam name="T">The type of data in the window</typeparam>
24  public interface IReadOnlyWindow<out T> : IEnumerable<T>
25  {
26  /// <summary>
27  /// Gets the size of this window
28  /// </summary>
29  int Size { get; }
30 
31  /// <summary>
32  /// Gets the current number of elements in this window
33  /// </summary>
34  int Count { get; }
35 
36  /// <summary>
37  /// Gets the number of samples that have been added to this window over its lifetime
38  /// </summary>
39  int Samples { get; }
40 
41  /// <summary>
42  /// Indexes into this window, where index 0 is the most recently
43  /// entered value
44  /// </summary>
45  /// <param name="i">the index, i</param>
46  /// <returns>the ith most recent entry</returns>
47  T this[int i] { get; }
48 
49  /// <summary>
50  /// Gets a value indicating whether or not this window is ready, i.e,
51  /// it has been filled to its capacity, this is when the Size==Count
52  /// </summary>
53  bool IsReady { get; }
54 
55  /// <summary>
56  /// Gets the most recently removed item from the window. This is the
57  /// piece of data that just 'fell off' as a result of the most recent
58  /// add. If no items have been removed, this will throw an exception.
59  /// </summary>
61  }
62 }