You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel.HNSW/Utils/VisitedBitSet.cs

33 lines
677 B

3 years ago
using System;
namespace ZeroLevel.HNSW
{
3 years ago
public class VisitedBitSet
3 years ago
{
// bit map
private int[] Buffer;
3 years ago
public VisitedBitSet(int nodesCount, int M)
3 years ago
{
Buffer = new int[(nodesCount >> 5) + M + 1];
}
3 years ago
public bool Contains(int nodeId)
3 years ago
{
int carrier = Buffer[nodeId >> 5];
return ((1 << (nodeId & 31)) & carrier) != 0;
}
3 years ago
public void Add(int nodeId)
3 years ago
{
int mask = 1 << (nodeId & 31);
Buffer[nodeId >> 5] |= mask;
}
3 years ago
public void Clear()
3 years ago
{
Array.Clear(Buffer, 0, Buffer.Length);
}
}
}

Powered by TurnKey Linux.