Set of extended collections related functionality.
ByteDev.Collections has been written as a .NET Standard 2.0 library, so you can consume it from a .NET Core or .NET Framework 4.6.1 (or greater) application.
ByteDev.Collections is hosted as a package on nuget.org. To install from the Package Manager Console in Visual Studio run:
Install-Package ByteDev.Collections
Further details can be found on the nuget page.
Releases follow semantic versioning.
Full details of the release notes can be viewed on GitHub.
To use any extension methods simply reference the ByteDev.Collections
namespace.
- Array []:
- Populate
- SafeLength
- Array [,]:
- GetColumn
- GetColumnCount
- GetRow
- GetRowCount
- Populate
- SafeLength
- ToSingleDimension
- IDictionary<TKey, TValue>:
- AddOrUpdate
- AddRange
- AddOrUpdateRange
- AddIfNotContainsKey
- ContainsAllKey
- ContainsAnyKey
- GetFirstValueIgnoreKeyCase
- GetValueOrDefault
- GetValuesIgnoreKeyCase
- RenameKey
- ToNameValueCollection
- ToReadOnlyDictionary
- IEnumerable:
- Second
- SecondOrDefault
- Third
- ThirdOrDefault
- Fourth
- FourthOrDefault
- Fifth
- FifthOrDefault
- Sixth
- SixthOrDefault
- Seventh
- SeventhOrDefault
- Eigth
- EigthOrDefault
- Ninth
- NinthOrDefault
- Tenth
- TenthOrDefault
- AllUnique
- Concat (params overloads)
- ContainsAll
- ContainsAny
- Last(int)
- MaxBy
- MinBy
- NullToEmpty
- ForEach
- Find
- IsEmpty
- IsNullOrEmpty
- IsSingle
- IsEquivalentTo
- ToCsv
- ToDelimitedString
- ToWrappedString
- IEnumerable:
- FirstLongest
- FirstShortest
- ICollection:
- AddIfNotContains
- AddIfNotNull
- AddRange
- Fill
- IsIndexValid
- RemoveRandom
- RemoveWhere
- TakeRandom
- IList:
- NullToEmpty
- MoveToFirst
- MoveToLast
- ReplaceAt
- ReplaceAll
- SafeGet
- Shuffle
- Swap
- NameValueCollection:
- AddOrUpdate
- AddIfNotContainsKey
- ContainsKey
- ToDictionary
- GenericExtensions:
- AsEnumerable
- AsList
- IEnumerator:
- MoveNext(int)
The Sequencer
class can be used to quickly create different sequences of numbers.
// Create different number sequences
using ByteDev.Collections.Sequences;
// ...
const int size = 8;
// 1, 1, 1, 1, 1, 1, 1, 1
IList<int> r = Sequencer.Repeating(size, 1);
// 1, 2, 3, 4, 5, 6, 7, 8
IList<int> n = Sequencer.Natural(size);
// 0, 1, 2, 3, 4, 5, 6, 7
IList<int> w = Sequencer.Whole(size);
// 0, 1, 2, 3, 4, 5, 6, 7
IList<int> i1 = Sequencer.Integers(size);
// -2, -1, 0, 1, 2, 3, 4, 5
IList<int> i2 = Sequencer.Integers(size, -2);
// 1, 3, 5, 7, 9, 11, 13, 15
IList<int> a = Sequencer.Arithmetic(size, 1, 2);
// 1, 2, 4, 8, 16, 32, 64, 128
IList<int> g = Sequencer.Geometric(size, 1, 2);
// 0, 1, 1, 2, 3, 5, 8, 13
IList<int> f = Sequencer.Fibonacci(size);
// 2, 3, 5, 7, 11, 13, 17, 19
IList<int> p = Sequencer.Primes(size);
// 10, 5, 16, 8, 4, 2, 1
IList<int> c = Sequencer.Collatz(10);
// 1, 3, 6, 10, 15, 21, 28, 36
IList<int> t = Sequencer.Triangular(size);
// 1, 4, 9, 16, 25, 36, 49, 64
IList<int> s = Sequencer.Square(size);
// 1, 8, 27, 64, 125, 216, 343, 512
IList<int> s = Sequencer.Cube(size);
// 2, 4, 8, 16, 32, 64, 128, 256
IList<int> p2 = Sequencer.PowerOfTwo(size);
// 0, 2, 4, 6, 8, 10, 12, 14
IList<int> e1 = Sequencer.Even(size);
// 4, 6, 8, 10, 12, 14, 16, 18
IList<int> e2 = Sequencer.Even(size, 4);
// 1, 3, 5, 7, 9, 11, 13, 15
IList<int> o1 = Sequencer.Odd(size);
// 3, 5, 7, 9, 11, 13, 15, 17
IList<int> o2 = Sequencer.Odd(size, 3);
// 1, 4, 10, 20, 35, 56, 84, 120
IList<int> tet = Sequencer.Tetrahedral(size, 3);