CVB.Net 15.0
Loading...
Searching...
No Matches
CollectionExtensions Class Reference

Extension methods for use with generic collections. More...

Static Public Member Functions

static IEnumerable< TObject > SortByName< TObject > (this IEnumerable< TObject > coll, SortDirection direction)
 Sort a list of named objects by the objects names.
 
static IEnumerable< TObject > SortByName< TObject > (this IEnumerable< TObject > coll)
 Sort a list of named objects by the objects names.
 
static string AsString< TObject > (this IEnumerable< TObject > coll)
 Convert a list of named object into a string (useful for example with the Minos classifier's 'Read' method).
 
static IEnumerable< TObject > Threshold< TObject > (this IEnumerable< TObject > coll, double threshold)
 Remove all values in a collection that lies below a threshold.
 
static IEnumerable< TObject > ThresholdAbsolute< TObject > (this IEnumerable< TObject > coll, double threshold)
 Remove all values in a collection that lies below a threshold.
 
static IEnumerable< TObject > SortByQuality< TObject > (this IEnumerable< TObject > coll, SortDirection direction)
 Sort a list of qualified objects by the objects qualities.
 
static IEnumerable< TObject > SortByQuality< TObject > (this IEnumerable< TObject > coll)
 Sort a list of qualified objects by the objects qualities.
 
static IEnumerable< TObject > SortByAbsoluteQuality< TObject > (this IEnumerable< TObject > coll, SortDirection direction)
 Sort by absolute quality values (may be useful where qualities can be negative like e.g. with the Edge tool, where in some search modes the sign of the quality indicates the edge polarity).
 
static IEnumerable< TObject > SortByAbsoluteQuality< TObject > (this IEnumerable< TObject > coll)
 Sort a list of qualified objects by the objects qualities.
 
static IEnumerable< TObject > SortBySize< TObject > (this IEnumerable< TObject > coll, SortDirection direction)
 Sort a list of sized objects by the objects qualities.
 
static IEnumerable< TObject > SortBySize< TObject > (this IEnumerable< TObject > coll)
 Sort a list of sized objects by the objects qualities.
 
static IEnumerable< TObject > SortByRotation< TObject > (this IEnumerable< TObject > coll, SortDirection direction)
 Sort a list of rotated objects by the objects qualities.
 
static IEnumerable< TObject > SortByRotation< TObject > (this IEnumerable< TObject > coll)
 Sort a list of rotated objects by the objects qualities.
 
static IEnumerable< TObject > SortByScale< TObject > (this IEnumerable< TObject > coll, SortDirection direction)
 Sort a list of scaled objects by the objects qualities.
 
static IEnumerable< TObject > SortByScale< TObject > (this IEnumerable< TObject > coll)
 Sort a list of scaled objects by the objects qualities.
 
static Point2Dd GetCenter< TObject > (this IEnumerable< TObject > list)
 Calculate the center of gravity over a list of position objects.
 
static IEnumerable< TObject > SortByPosition< TObject > (this IEnumerable< TObject > list, IPosition sortDirection)
 Sort a list of position objects by their sortDirection to a sort direction.
 
static IEnumerable< TObject > SortByDistance< TObject > (this IEnumerable< TObject > coll, IPosition sortCenter, SortDirection sortDirection)
 Sort a list of positions according to their distances from a sort center.
 
static IEnumerable< TObject > SortByDistance< TObject > (this IEnumerable< TObject > coll, IPosition sortCenter)
 Sort a list of position according to their distances form a sort center.
 
static IEnumerable< TObject > SeparateByQuality< TObject > (this IEnumerable< TObject > coll, double locality)
 Makes sure the results in this list are separated by at least locality pixels (measured using the L1 norm). The separations is being carried out as follows:

  1. First of all the list of results will be sorted by descending quality
  2. Then the list will iterated from the element with the highest quality to the element with the lowest quality
  3. For each element being iterated the distance to all subsequent list elements (i.e. those list elements with a lower quality) will be calculated; if it is less than the locality parameter, the element with the lower quality will be eliminated from the list

 
static IEnumerable< TObject > SeparatePositions< TObject > (this IEnumerable< TObject > coll, double locality)
 Makes sure the results in this list are separated by at least locality pixels (measured using the L1 norm). The separations is being carried out as follows:

  1. It is assumed that the list is already sorted "best to worst" according to whatever criterion is suitable
  2. Then the list will iterated from the first element to the last element
  3. For each element being iterated the distance to all subsequent list elements (i.e. those list elements with a lower quality) will be calculated; if it is less than the locality parameter, the element that came last will be eliminated from the list

 
static IEnumerable< TObject > SeparateBySize< TObject > (this IEnumerable< TObject > coll, double locality)
 Makes sure the results in this list are separated by at least locality pixels (measured using the L1 norm). The separations is being carried out as follows:

  1. First of all the list of results will be sorted by descending quality
  2. Then the list will iterated from the element with the highest quality to the element with the lowest quality
  3. For each element being iterated the distance to all subsequent list elements (i.e. those list elements with a lower quality) will be calculated; if it is less than the locality parameter, the element with the lower quality will be eliminated from the list

 
static double FindQuantil (this IEnumerable< double > en, double p)
 Find the Quantile defined by p .
 
static double FindQuantil (this IEnumerable< double > en, double p, SortStatus sorted=SortStatus.Unsorted)
 Find the Quantile defined by p .
 
static void Swap< TValue > (this TValue[] arr, int index1, int index2)
 Swap two elements of an array.
 

Detailed Description

Extension methods for use with generic collections.

Member Function Documentation

◆ AsString< TObject >()

static string AsString< TObject > ( this IEnumerable< TObject > coll)
static

Convert a list of named object into a string (useful for example with the Minos classifier's 'Read' method).

Template Parameters
TObject
Parameters
coll
Returns
Type Constraints
TObject :INamed 

◆ FindQuantil() [1/2]

static double FindQuantil ( this IEnumerable< double > en,
double p )
static

Find the Quantile defined by p .

Parameters
enCollection on which to find.
pquantile to find
Returns
quantil

◆ FindQuantil() [2/2]

static double FindQuantil ( this IEnumerable< double > en,
double p,
SortStatus sorted = SortStatus::Unsorted )
static

Find the Quantile defined by p .

Parameters
enCollection on which to find.
pquantile to find
sortedSpecifies whether en is sorted.
Returns
quantil

◆ GetCenter< TObject >()

static Point2Dd GetCenter< TObject > ( this IEnumerable< TObject > list)
static

Calculate the center of gravity over a list of position objects.

Template Parameters
TObjectobject type
Parameters
listlist to calculate on
Returns
the list's center position
Type Constraints
TObject :IPosition 

◆ SeparateByQuality< TObject >()

static IEnumerable< TObject > SeparateByQuality< TObject > ( this IEnumerable< TObject > coll,
double locality )
static

Makes sure the results in this list are separated by at least locality pixels (measured using the L1 norm). The separations is being carried out as follows:

  1. First of all the list of results will be sorted by descending quality
  2. Then the list will iterated from the element with the highest quality to the element with the lowest quality
  3. For each element being iterated the distance to all subsequent list elements (i.e. those list elements with a lower quality) will be calculated; if it is less than the locality parameter, the element with the lower quality will be eliminated from the list

Template Parameters
TObjecttype of the result comparable objects to be separated
Parameters
collcollection to which to apply the separation
localityminimum distance between two results (must be > 0)
Type Constraints
TObject :IPosition 
TObject :IQualified 

◆ SeparateBySize< TObject >()

static IEnumerable< TObject > SeparateBySize< TObject > ( this IEnumerable< TObject > coll,
double locality )
static

Makes sure the results in this list are separated by at least locality pixels (measured using the L1 norm). The separations is being carried out as follows:

  1. First of all the list of results will be sorted by descending quality
  2. Then the list will iterated from the element with the highest quality to the element with the lowest quality
  3. For each element being iterated the distance to all subsequent list elements (i.e. those list elements with a lower quality) will be calculated; if it is less than the locality parameter, the element with the lower quality will be eliminated from the list

Template Parameters
TObjecttype of the result comparable objects to be separated
Parameters
collcollection to which to apply the separation
localityminimum distance between two results (must be > 0)
Type Constraints
TObject :IPosition 
TObject :ISized 

◆ SeparatePositions< TObject >()

static IEnumerable< TObject > SeparatePositions< TObject > ( this IEnumerable< TObject > coll,
double locality )
static

Makes sure the results in this list are separated by at least locality pixels (measured using the L1 norm). The separations is being carried out as follows:

  1. It is assumed that the list is already sorted "best to worst" according to whatever criterion is suitable
  2. Then the list will iterated from the first element to the last element
  3. For each element being iterated the distance to all subsequent list elements (i.e. those list elements with a lower quality) will be calculated; if it is less than the locality parameter, the element that came last will be eliminated from the list

Template Parameters
TObjecttype of the result comparable objects to be separated
Parameters
collcollection to which to apply the separation
localityminimum distance between two results (must be > 0)
Type Constraints
TObject :IPosition 

◆ SortByAbsoluteQuality< TObject >() [1/2]

static IEnumerable< TObject > SortByAbsoluteQuality< TObject > ( this IEnumerable< TObject > coll)
static

Sort a list of qualified objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
Type Constraints
TObject :IQualified 

◆ SortByAbsoluteQuality< TObject >() [2/2]

static IEnumerable< TObject > SortByAbsoluteQuality< TObject > ( this IEnumerable< TObject > coll,
SortDirection direction )
static

Sort by absolute quality values (may be useful where qualities can be negative like e.g. with the Edge tool, where in some search modes the sign of the quality indicates the edge polarity).

Template Parameters
TObjectobject tyle
Parameters
collcollection to be sorted
directionsort order
Type Constraints
TObject :IQualified 

◆ SortByDistance< TObject >() [1/2]

static IEnumerable< TObject > SortByDistance< TObject > ( this IEnumerable< TObject > coll,
IPosition sortCenter )
static

Sort a list of position according to their distances form a sort center.

Template Parameters
TObjecttype of object to be sorted
Parameters
collcollection to be sorted
sortCentercenter around which to sort
Type Constraints
TObject :IPosition 

◆ SortByDistance< TObject >() [2/2]

static IEnumerable< TObject > SortByDistance< TObject > ( this IEnumerable< TObject > coll,
IPosition sortCenter,
SortDirection sortDirection )
static

Sort a list of positions according to their distances from a sort center.

Template Parameters
TObjecttype of object to be sorted
Parameters
collcollection to be sorted
sortCentercenter around which to sort
sortDirectionsort direction
Type Constraints
TObject :IPosition 

◆ SortByName< TObject >() [1/2]

static IEnumerable< TObject > SortByName< TObject > ( this IEnumerable< TObject > coll)
static

Sort a list of named objects by the objects names.

Template Parameters
TObjectobject type
Parameters
colllist to be sorted
Type Constraints
TObject :INamed 

◆ SortByName< TObject >() [2/2]

static IEnumerable< TObject > SortByName< TObject > ( this IEnumerable< TObject > coll,
SortDirection direction )
static

Sort a list of named objects by the objects names.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
directionsort order
Type Constraints
TObject :INamed 

◆ SortByPosition< TObject >()

static IEnumerable< TObject > SortByPosition< TObject > ( this IEnumerable< TObject > list,
IPosition sortDirection )
static

Sort a list of position objects by their sortDirection to a sort direction.

Template Parameters
TObjectobject type
Parameters
listlist to be sorted
sortDirectionvector that gives the direction in which to order the objects
Type Constraints
TObject :IPosition 

◆ SortByQuality< TObject >() [1/2]

static IEnumerable< TObject > SortByQuality< TObject > ( this IEnumerable< TObject > coll)
static

Sort a list of qualified objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
Type Constraints
TObject :IQualified 

◆ SortByQuality< TObject >() [2/2]

static IEnumerable< TObject > SortByQuality< TObject > ( this IEnumerable< TObject > coll,
SortDirection direction )
static

Sort a list of qualified objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
directionsort order
Type Constraints
TObject :IQualified 

◆ SortByRotation< TObject >() [1/2]

static IEnumerable< TObject > SortByRotation< TObject > ( this IEnumerable< TObject > coll)
static

Sort a list of rotated objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
Type Constraints
TObject :IRotated 

◆ SortByRotation< TObject >() [2/2]

static IEnumerable< TObject > SortByRotation< TObject > ( this IEnumerable< TObject > coll,
SortDirection direction )
static

Sort a list of rotated objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
directionsort order
Type Constraints
TObject :IRotated 

◆ SortByScale< TObject >() [1/2]

static IEnumerable< TObject > SortByScale< TObject > ( this IEnumerable< TObject > coll)
static

Sort a list of scaled objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
Type Constraints
TObject :IScaled 

◆ SortByScale< TObject >() [2/2]

static IEnumerable< TObject > SortByScale< TObject > ( this IEnumerable< TObject > coll,
SortDirection direction )
static

Sort a list of scaled objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
directionsort order
Type Constraints
TObject :IScaled 

◆ SortBySize< TObject >() [1/2]

static IEnumerable< TObject > SortBySize< TObject > ( this IEnumerable< TObject > coll)
static

Sort a list of sized objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
Type Constraints
TObject :ISized 

◆ SortBySize< TObject >() [2/2]

static IEnumerable< TObject > SortBySize< TObject > ( this IEnumerable< TObject > coll,
SortDirection direction )
static

Sort a list of sized objects by the objects qualities.

Template Parameters
TObjectobject type
Parameters
collcollection to be sorted
directionsort order
Type Constraints
TObject :ISized 

◆ Swap< TValue >()

static void Swap< TValue > ( this TValue[] arr,
int index1,
int index2 )
static

Swap two elements of an array.

Template Parameters
TValuetype of the elements stored in the array
Parameters
arrthe array to attach the extension method to
index1element one to swap
index2element two to swap
Exceptions
ArgumentOutOfRangeExceptionIf index1 or index2 is either less than 0 or greater than the length of the array

◆ Threshold< TObject >()

static IEnumerable< TObject > Threshold< TObject > ( this IEnumerable< TObject > coll,
double threshold )
static

Remove all values in a collection that lies below a threshold.

Template Parameters
TObjectobject type
Parameters
colllist to be thresholded
thresholdthreshold to apply
Type Constraints
TObject :IQualified 

◆ ThresholdAbsolute< TObject >()

static IEnumerable< TObject > ThresholdAbsolute< TObject > ( this IEnumerable< TObject > coll,
double threshold )
static

Remove all values in a collection that lies below a threshold.

Template Parameters
TObjectobject type
Parameters
colllist to be thresholded
thresholdthreshold to apply
Type Constraints
TObject :IQualified