Releases: JeevanJames/Collections
v1.6.0
Change log
- Added overloads to the
Union
extension that allow single values to be added.
Where earlier you would have done this:
var nums = new int[] { 1, 2, 3, 4, 5, 6 };
nums.Union(new[] { 7 });
You can now do this:
var nums = new int[] { 1, 2, 3, 4, 5, 6 };
nums.Union(7);
Another Union
overload accepts a params
parameter:
var nums = new int[] { 1, 2, 3, 4, 5, 6 };
nums.Union(7, 8, 9);
-
Added an
AllOrNone
extension onIEnumerable<T>
that determines whether a predicate matches all or none of the elements in a sequence. -
Added an
IsNotNullOrEmpty
extension, which is the opposite ofIsNullOrEmpty
.
v1.5.0
Change log
- Added collection extensions for additional integral types -
char
,int
,long
andshort
.
v1.4.0
Change log
-
Added
SlidingChunk
extension method, which returns overlapping consecutive chunks of a specified size from a collection.This is different from the
Chunk
extension method, which returns non-overlapping chunks.
var collection = new List<int> {1, 2, 3, 4, 5, 6};
var chunks = collection.Chunk(2);
// returns { {1, 2}, {3, 4}, {5, 6} }
var slidingChunks = collection.SlidingChunk(2);
// returns { {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6} }
v1.3.0
Change log
-
ForEach
methods now return the original collection to allow for fluent syntax. -
The
AddRange
overload that accepts a predicate and a converter takes an additional parameter - a predicate that works on the converted data. The first predicate parameter works on the data before it is converted.
var list = new List<int> {1, 2, 3};
var dataToAdd = new[] {"7", "8", "9", "10", "11", "12"};
list.Add(dataToAdd,
s => s.Length == 1, // Predicate on string - only strings of length 1
s => int.Parse, // Converter - converts string to int
n => n % 2 == 0); // Predicate on int - only even numbers
- Added
InsertRange
extension methods onIList<T>
that inserts one or more items to a collection at a specific location.
Low impact breaking changes
-
Moved methods from
CollectionExtensions
class to other classes based on the interface they are extending. So, methods that extendIEnumerable<T>
are moved toEnumerableExtensions
and methods that extendIList<T>
are moved toListExtensions
. Methods that extendICollection<T>
remain in the same class.This is only a breaking change if you call these methods as static methods instead of as extension methods.
int[] array = new int[10];
// Calling as a static method - This will break
CollectionExtensions.Fill(array, 7);
// Calling as an extension method - This will not break
array.Fill(7);
v1.0.0-beta.2
Change log
- Added collection extensions, byte array extensions and enum iterator.
- Added unit tests. Currently at 68.6% coverage.