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

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

Powered by TurnKey Linux.