The Wayback Machine - https://web.archive.org/web/20201002184844/https://github.com/SoftCircuits/SparseCollections
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

ReadMe.md

Buy Me A Coffee

Sparse Collections

NuGet version (SoftCircuits.SparseCollections)

Install-Package SoftCircuits.SparseCollections

Overview

The SparseCollections library includes two lightweight collection classes, SparseArray<T> and SparseMatrix<T>. The array class allows statements such as array[1000000] = 5 and array[-1000000] = 6 without having to allocate a large array. The matrix class works similarly except as a two-dimensional array.

Examples

This example adds two items to a SparseArray<T> and confirms their value.

SparseArray<int> array = new SparseArray<int>();

// Assign some values
array[10000] = 4;
array[-100000] = 5;

// Confirm values
Debug.Assert(array[10000] == 4);
Debug.Assert(array[-100000] == 5);

This example does the same thing with a SparseMatrix<T>.

SparseMatrix<int> matrix = new SparseMatrix<int>();

// Assign some values
matrix[10000, -10000] = 4;
matrix[-100000, 20000] = 5;

// Confirm values
Debug.Assert(matrix[10000, -10000] == 4);
Debug.Assert(matrix[-100000, 20000] == 5);

About

The SparseCollections library provides the SparseArray<T> and SparseMatrix<T> collection classes.

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.