In This Topic
A data series subset is a set of indexes and(or) ranges of indexes. Each data series subset is represented by an instance of NDataSeriesSubset class. Subsets are returned or required as arguments by various data manipulation functions.
The user can perform the following operations with subsets.
Add indexes and ranges of indexes
The user adds indexes or ranges of indexes in the subset with the help of the AddIndex and AddRange methods. The following code adds indexes 3, 5, 6, 7 and 8 in a newly created subset.
C# |
Copy Code
|
NDataSeriesSubset subset = new NDataSeriesSubset();
subset.AddIndex(3);
subset.AddRange(5, 8);
|
Visual Basic |
Copy Code
|
Dim subset As NDataSeriesSubset = New NDataSeriesSubset()
subset.AddIndex(3)
subset.AddRange(5, 8)
|
Remove indexes and ranges of indexes
The user can remove indexes from a subset with the help of the RemoveIndex and RemoveRange methods. The following code will remove index 8 and all indexes in the 3 - 5 range. Thus the subset will contain indexes 6 and 7.
C# |
Copy Code
|
subset.RemoveIndex(8);
subset.RemoveRange(3, 5);
|
Visual Basic |
Copy Code
|
subset.RemoveIndex(8)
subset.RemoveRange(3, 5)
|
Determine whether an index is contained in a subset
The user can query whether a specific index is contained in the subset with the help of the Contains method. The first call in the following example will return true while the second call will fail.
C# |
Copy Code
|
bool bContains;
bContains = subset.Contains(6);
bContains = subset.Contains(3);
|
Visual Basic |
Copy Code
|
Dim bContains As Boolean
bContains = subset.Contains(6)
bContains = subset.Contains(3)
|
Iterate through the indexes contained in the subset
The NDataSeriesSubset class implements the IEnumerable interface. The following examples enumerates all indexes in a subset:
C# |
Copy Code
|
// enumerate using a foreach statement
foreach (int index in subset)
{
// do something for this index
}
// enumerate using the standard IEnumerable
IEnumerator it = subset.GetEnumerator();
while (it.MoveNext())
{
int index = (int)it.Current;
// do something for this index
}
|
Visual Basic |
Copy Code
|
' enumerate using a foreach statement
For Each index As Integer In subset
' do something for this index
Next
' enumerate using the standard IEnumerable
Dim it As IEnumerator = subset.GetEnumerator()
While it.MoveNext()
Dim index As Integer = CType(it.Current, Integer)
' do something for this index
End While
|
Perform set operations with other subsets
The user can perform the following set operations with another subset:
-
Combine (logical equivalent of OR)
The combine operation is performed by the Combine method. After the operation the subset will contain all indexes specified in current and parameter subsets. For example:
C# |
Copy Code
|
NDataSeriesSubset paramSubset = new NDataSeriesSubset();
paramSubset.AddIndex(7);
paramSubset.AddIndex(9);
subset.Combine(paramSubset);
|
Visual Basic |
Copy Code
|
Dim paramSubset As NDataSeriesSubset = New NDataSeriesSubset()
paramSubset.AddIndex(7)
paramSubset.AddIndex(9)
subset.Combine(paramSubset)
|
-
Subtract
The intersect operation is performed by the Subtract method. After the operation the subset will contain only indexes that were contained in the subset and were not members of the paramSubset. For example:
C# |
Copy Code
|
subset.Clear();
subset.AddRange(6, 7);
subset.Subtract(paramSubset);
|
Visual Basic |
Copy Code
|
subset.Clear()
subset.AddRange(6, 7)
subset.Subtract(paramSubset)
|
Extract or remove a subset from a single data series
The user can extract or remove the indexes contained in a data series subset from a data series. These operations are performed by the RemoveSubset and ExtractSubset methods of the NDataSeries class. The RemoveSubset removes the data items which are contained at the indexes specified in the subset. On the other hand the ExtractSubset method will remove all items which are positioned on indexes not contained in the subset.
Extract or remove a subset from multiple data series
The RemoveSubset and ExtractSubset methods of the NDataSeriesCollection class allow a subset to be removed or extracted from a set of aligned data series.
Related Examples
Windows forms: All Examples\Data Manipulation\General\Filtering
Windows forms: All Examples\Data Manipulation\General\Evaluating
See Also