Skip to content
/ IntSet Public

This data structure is a set of integer values. It works 2 times faster than HashSet<int> and takes up much less memory.

Notifications You must be signed in to change notification settings

Kibnet/IntSet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IntSet IntSet

GitHub last commit

GitHub search hit counter Nuget GitHub code size in bytes

What is it?

It is a specialized data structure for storing a set of integers of type Int32.

Unlike the universal HashSet, numbers are not stored explicitly, but are packed into compact ordered structures. This allows you to save on the used RAM for large set sizes. In the worst case, the structure takes up ~525 MB in memory, while it can contain the full range of Int32 numbers. A hashset with such volumes consumes tens of gigabytes.

The structure implements the standard ISet interface, and can be used in all scenarios instead of HashSet. Also IntSet implements the IEnumerable interface, which enumerate numbers in ascending order without overhead.

How to use?

The structure is designed as a Net Standard 2.1 library that can be used in any compatible projects.

To use it, install the nuget package:

Install-Package IntSet

Usage Example

using Kibnet;
var intSet = new IntSet();
intSet.Add(123);
var isContains = intSet.Contains(123);
intSet.Remove(123);

What is your proof?

The repository has tests that show that everything works as it should.

I also have a code with benchmarks that shows superiority over HashSet in the operations of adding, deleting, and contains. I will publish it in this repository after I bring it to an acceptable form.

Benchmarks

This project includes benchmarks to compare the performance and memory usage of IntSet against the standard System.Collections.Generic.HashSet<int>. The benchmarks are implemented using BenchmarkDotNet.

Running the Benchmarks

To run the benchmarks:

  1. Navigate to the benchmark project directory:
    cd src/IntSet.Benchmarks
  2. Run the benchmark project:
    dotnet run -c Release
    It is highly recommended to run benchmarks in Release configuration for accurate results.

Benchmark Results

The benchmark results will be displayed in the console after the run completes. Additionally, BenchmarkDotNet will generate detailed reports (including markdown files, CSV files, and plots) in a BenchmarkDotNet.Artifacts directory within src/IntSet.Benchmarks/bin/Release/netX.X/ (where netX.X is the target framework, e.g., net9.0).

About

This data structure is a set of integer values. It works 2 times faster than HashSet<int> and takes up much less memory.

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors 2

  •  
  •  

Languages