Interface ICodeMetric<TCodeElement, TNumeric>
Represent a code metric, a correspondance between a set of code elements and some numerical values.
public interface ICodeMetric<TCodeElement, TNumeric> : IEnumerable<ICodeMetricValue<TCodeElement, TNumeric>>, IEnumerable where TCodeElement : class, ICodeElement where TNumeric : struct
Type Parameters
TCodeElementThe code element type that is ICodeElement or that implements ICodeElement.
TNumericThe numeric value type that is one of these type: byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal.
- Inherited Members
- Extension Methods
Remarks
A code metric object is returned by extension methods of ExtensionMethodsSequenceUsage defined on sequences of code elements.
A custom code metric object can also be created through the particular method ExtensionMethodsHelpers.FillIterative<TCodeElement>(IEnumerable<TCodeElement>, Func<IEnumerable<TCodeElement>, IEnumerable<TCodeElement>>).
Properties (6)
DefinitionDomain
Gets the sequence of code elements for which this code metric is defined.
IEnumerable<TCodeElement> DefinitionDomain { get; }
Property Value
- IEnumerable<TCodeElement>
Remarks
This method has a O(DefinitionDomainCount) time complexity.
DefinitionDomainCount
Gets the number of code elements for which this code metric is defined.
int DefinitionDomainCount { get; }
Property Value
Remarks
This method has a constant time complexity.
this[TCodeElement]
Gets this code metric value for codeElement. Gets null if the metric is not defined for codeElement.
TNumeric? this[TCodeElement codeElement] { get; }
Parameters
codeElementTCodeElementThe code element.
Property Value
- TNumeric?
Remarks
This accessor is equivalent to the method ValueOf(TCodeElement).
This method has a constant time complexity.
MaxValue
Gets the the maximum value in this.Values.
TNumeric? MaxValue { get; }
Property Value
- TNumeric?
Remarks
If this.DefinitionDomainCount is zero, returns null.
This method has a O(DefinitionDomainCount) time complexity.
MinValue
Gets the the minimum value in this.Values.
TNumeric? MinValue { get; }
Property Value
- TNumeric?
Remarks
If this.DefinitionDomainCount is zero, returns null.
This method has a O(DefinitionDomainCount) time complexity.
Values
Gets the sequence of this code metric values taken by all code elements in this.DefinitionDomain. Numeric values are sorted with an ascending order in the sequence.
IEnumerable<TNumeric> Values { get; }
Property Value
- IEnumerable<TNumeric>
Remarks
Gets an empty sequence if DefinitionDomain is empty.
Notice that this.Values.Count() can be lower than this.DefinitionDomainCount if several code elements have the same value.
This method has a O(DefinitionDomainCount) time complexity.
Methods (3)
DefinedFor(TCodeElement)
Gets a value indicating whether this code metric is defined for codeElement.
bool DefinedFor(TCodeElement codeElement)
Parameters
codeElementTCodeElementThe code element.
Returns
Remarks
This method has a constant time complexity.
ElementsWithValue(TNumeric)
Gets the sequence of code elements for which, this code metric value is equal to value Gets an empty sequence if no code element are matched.
IEnumerable<TCodeElement> ElementsWithValue(TNumeric value)
Parameters
valueTNumericThe value.
Returns
- IEnumerable<TCodeElement>
Remarks
This method has a O(DefinitionDomainCount) time complexity.
ValueOf(TCodeElement)
Gets this code metric value for codeElement. Gets null if the metric is not defined for codeElement.
TNumeric? ValueOf(TCodeElement codeElement)
Parameters
codeElementTCodeElementThe code element.
Returns
- TNumeric?
Remarks
This method has a constant time complexity.