static class · System
Lists
public static class Lists
What List<T> offers when its items can be compared or tested for equality.
- Kind
- static class
- Namespace
- System
- Assembly
- System.Core
- Access
- public, static, abstract
- Source file
Array.ant
Inheritance
- Base classes
-
AnyLists
Methods
The total of a list of numbers (0 when empty).
The smallest and largest; the list must not be empty.
Sort<T : IComparable<T>>(List<T> list)
#
Takes out the first item equal to value; false when there is none.
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
Lists as Antril, decompiled from its Larva HIR.
// System.Lists — System.Core (decompiled from Larva HIR)
into namespace System
{
/// What List<T> offers when its items can be compared or tested for equality.
public static class Lists
{
public:
/// The total of a list of numbers (0 when empty).
Sum<T : INumber<T>>(List<T> list) : T => Array.Sum(list.Items(), 0, list.Count);
/// The smallest and largest; the list must not be empty.
Min<T : INumber<T>>(List<T> list) : T => Array.Min(list.Items(), 0, list.Count);
Max<T : INumber<T>>(List<T> list) : T => Array.Max(list.Items(), 0, list.Count);
Average<T : INumber<T>, (f64)T>(List<T> list) : f64 => (f64)Sum(list) / (f64)list.Count;
Sort<T : IComparable<T>>(List<T> list)
{
Array.Sort(list.Items(), 0, list.Count);
}
IndexOf<T : IHashable<T>>(List<T> list, T value) : i32
{
T[] items = list.Items();
loop (i32 i = 0..list.Count)
{
if (items[i].Equals(value))
return i;
}
return -1;
}
Contains<T : IHashable<T>>(List<T> list, T value) : bool => IndexOf(list, value) >= 0;
/// Takes out the first item equal to `value`; false when there is none.
Remove<T : IHashable<T>>(List<T> list, T value) : bool
{
i32 at = IndexOf(list, value);
if (at < 0)
return false;
list.RemoveAt(at);
return true;
}
}
}