Class RollingPointPairList
A class that provides a rolling list of PointPair objects. This is essentially a first-in-first-out (FIFO) queue with a fixed capacity which allows 'rolling' (or oscilloscope like) graphs to be be animated without having the overhead of an ever-growing ArrayList.
The queue is constructed with a fixed capacity and new points can be enqueued. When the capacity is reached the oldest (first in) PointPair is overwritten. However, when accessing via IPointList, the PointPair objects are seen in the order in which they were enqeued.
RollingPointPairList supports data editing through the IPointListEdit interface.
Inherited Members
Namespace: ZedGraph
Assembly: ZedGraph.dll
Syntax
[Serializable]
public class RollingPointPairList : ISerializable, IPointListEdit, IPointList, ICloneable
Constructors
| Improve this Doc View SourceRollingPointPairList(Int32)
Constructs an empty buffer with the specified capacity.
Declaration
public RollingPointPairList(int capacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | Number of elements in the rolling list. This number cannot be changed once the RollingPointPairList is constructed. |
RollingPointPairList(Int32, Boolean)
Constructs an empty buffer with the specified capacity. Pre-allocates space
for all PointPair's in the list if preLoad
is true.
Declaration
public RollingPointPairList(int capacity, bool preLoad)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | Number of elements in the rolling list. This number cannot be changed once the RollingPointPairList is constructed. |
Boolean | preLoad | true to pre-allocate all PointPair instances in the list, false otherwise. Note that in order to be memory efficient, the Add(Double, Double, Double) method should be used to add data. Avoid the Add(PointPair) method. |
See Also
| Improve this Doc View SourceRollingPointPairList(SerializationInfo, StreamingContext)
Constructor for deserializing objects
Declaration
protected RollingPointPairList(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | A SerializationInfo instance that defines the serialized data |
StreamingContext | context | A StreamingContext instance that contains the serialized data |
RollingPointPairList(IPointList)
Constructs a buffer with a copy of the items within the provided IPointList. The Capacity is set to the length of the provided list.
Declaration
public RollingPointPairList(IPointList rhs)
Parameters
Type | Name | Description |
---|---|---|
IPointList | rhs | The IPointList to be copied. |
Fields
| Improve this Doc View Source_headIdx
The index of the previously enqueued item. -1 if buffer is empty.
Declaration
[CLSCompliant(false)]
protected int _headIdx
Field Value
Type | Description |
---|---|
Int32 |
_mBuffer
An array of PointPair objects that acts as the underlying buffer.
Declaration
[CLSCompliant(false)]
protected PointPair[] _mBuffer
Field Value
Type | Description |
---|---|
PointPair[] |
_tailIdx
The index of the next item to be dequeued. -1 if buffer is empty.
Declaration
[CLSCompliant(false)]
protected int _tailIdx
Field Value
Type | Description |
---|---|
Int32 |
schema
Current schema value that defines the version of the serialized file
Declaration
public const int schema = 10
Field Value
Type | Description |
---|---|
Int32 |
Properties
| Improve this Doc View SourceCapacity
Gets the capacity of the rolling buffer.
Declaration
public int Capacity { get; }
Property Value
Type | Description |
---|---|
Int32 |
Count
Gets the count of items within the rolling buffer. Note that this may be less than the capacity.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
IsEmpty
Gets a bolean that indicates if the buffer is empty. Alternatively you can test Count==0.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int32]
Gets or sets the PointPair at the specified index in the buffer.
Declaration
public PointPair this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
Property Value
Type | Description |
---|---|
PointPair |
Remarks
Index must be within the current size of the buffer, e.g., the set method will not expand the buffer even if Capacity is available
Methods
| Improve this Doc View SourceAdd(Double, Double)
Add a set of values onto the head of the queue, overwriting old values if the buffer is full.
Declaration
public void Add(double x, double y)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The X value |
Double | y | The Y value |
Remarks
This method is much more efficient that the Add(PointPair) method, since it does not require that a new PointPair instance be provided. If the buffer already contains a PointPair at the head position, then the x, y, z, and tag values will be copied into the existing PointPair. Otherwise, a new PointPair instance must be created. In this way, each PointPair position in the rolling list will only be allocated one time. To truly be memory efficient, the Remove(), RemoveAt(Int32), and Pop() methods should be avoided.
Add(Double, Double, Double)
Add a set of values onto the head of the queue, overwriting old values if the buffer is full.
Declaration
public void Add(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The X value |
Double | y | The Y value |
Double | z | The Z value |
Remarks
This method is much more efficient that the Add(PointPair) method, since it does not require that a new PointPair instance be provided. If the buffer already contains a PointPair at the head position, then the x, y, z, and tag values will be copied into the existing PointPair. Otherwise, a new PointPair instance must be created. In this way, each PointPair position in the rolling list will only be allocated one time. To truly be memory efficient, the Remove(), RemoveAt(Int32), and Pop() methods should be avoided.
Add(Double, Double, Double, Object)
Add a set of values onto the head of the queue, overwriting old values if the buffer is full.
Declaration
public void Add(double x, double y, double z, object tag)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The X value |
Double | y | The Y value |
Double | z | The Z value |
Object | tag | The Tag value for the PointPair |
Remarks
This method is much more efficient that the Add(PointPair)
method, since it does not require that a new PointPair instance be provided.
If the buffer already contains a PointPair at the head position,
then the x, y, z, and tag values will be copied into the existing PointPair.
Otherwise, a new PointPair instance must be created.
In this way, each PointPair position in the rolling list will only be allocated one time.
To truly be memory efficient, the Remove(), RemoveAt(Int32),
and Pop() methods should be avoided. Also, the tag
property
for this method should be null, since it is a reference type.
Add(Double, Double, Object)
Add a set of values onto the head of the queue, overwriting old values if the buffer is full.
Declaration
public void Add(double x, double y, object tag)
Parameters
Type | Name | Description |
---|---|---|
Double | x | The X value |
Double | y | The Y value |
Object | tag | The Tag value for the PointPair |
Remarks
This method is much more efficient that the Add(PointPair)
method, since it does not require that a new PointPair instance be provided.
If the buffer already contains a PointPair at the head position,
then the x, y, z, and tag values will be copied into the existing PointPair.
Otherwise, a new PointPair instance must be created.
In this way, each PointPair position in the rolling list will only be allocated one time.
To truly be memory efficient, the Remove(), RemoveAt(Int32),
and Pop() methods should be avoided. Also, the tag
property
for this method should be null, since it is a reference type.
Add(Double[], Double[])
Add a set of points to the RollingPointPairList from two arrays of type double. If either array is null, then a set of ordinal values is automatically generated in its place (see Ordinal). If the arrays are of different size, then the larger array prevails and the smaller array is padded with Missing values.
Declaration
public void Add(double[] x, double[] y)
Parameters
Type | Name | Description |
---|---|---|
Double[] | x | A double[] array of X values |
Double[] | y | A double[] array of Y values |
Add(Double[], Double[], Double[])
Add a set of points to the RollingPointPairList from
three arrays of type double.
If the X or Y array is null, then a set of ordinal values is automatically
generated in its place (see Ordinal.
If the
Declaration
public void Add(double[] x, double[] y, double[] z)
Parameters
Type | Name | Description |
---|---|---|
Double[] | x | A double[] array of X values |
Double[] | y | A double[] array of Y values |
Double[] | z | A double[] array of Z values |
Add(IPointList)
Add an IPointList object to the head of the queue.
Declaration
public void Add(IPointList pointList)
Parameters
Type | Name | Description |
---|---|---|
IPointList | pointList | A reference to the IPointList object to be added |
Add(PointPair)
Add a PointPair onto the head of the queue, overwriting old values if the buffer is full.
Declaration
public void Add(PointPair item)
Parameters
Type | Name | Description |
---|---|---|
PointPair | item | The PointPair to be added. |
Clear()
Declaration
public void Clear()
Clone()
Typesafe, deep-copy clone method.
Declaration
public RollingPointPairList Clone()
Returns
Type | Description |
---|---|
RollingPointPairList | A new, independent copy of this class |
GetObjectData(SerializationInfo, StreamingContext)
Populates a SerializationInfo instance with the data needed to serialize the target object
Declaration
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | A SerializationInfo instance that defines the serialized data |
StreamingContext | context | A StreamingContext instance that contains the serialized data |
Peek()
Peek at the PointPair item at the head of the queue.
Declaration
public PointPair Peek()
Returns
Type | Description |
---|---|
PointPair | The PointPair item at the head of the queue. Throws an InvalidOperationException if the buffer was empty. |
Pop()
Pop an item off the head of the queue.
Declaration
public PointPair Pop()
Returns
Type | Description |
---|---|
PointPair | The popped item. Throws an exception if the buffer was empty. |
Remove()
Remove an old item from the tail of the queue.
Declaration
public PointPair Remove()
Returns
Type | Description |
---|---|
PointPair | The removed item. Throws an InvalidOperationException if the buffer was empty. Check the buffer's length (Count) or the IsEmpty property to avoid exceptions. |
RemoveAt(Int32)
Remove the PointPair at the specified index
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The ordinal position of the item to be removed. Throws an ArgumentOutOfRangeException if index is less than zero or greater than or equal to Count |
Remarks
All items in the queue that lie after index
will
be shifted back by one, and the queue will be one item shorter.
RemoveRange(Int32, Int32)
Remove a range of PointPair objects starting at the specified index
Declaration
public void RemoveRange(int index, int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The ordinal position of the item to be removed. Throws an ArgumentOutOfRangeException if index is less than zero or greater than or equal to Count |
Int32 | count | The number of items to be removed. Throws an
ArgumentOutOfRangeException if |
Remarks
All items in the queue that lie after index
will
be shifted back, and the queue will be count
items shorter.
Explicit Interface Implementations
| Improve this Doc View SourceICloneable.Clone()
Implement the ICloneable interface in a typesafe manner by just calling the typed version of Clone()
Declaration
object ICloneable.Clone()
Returns
Type | Description |
---|---|
Object | A deep copy of this object |