Show / Hide Table of Contents

    Class SentinelInt32Set

    A native hash-based set where one value is reserved to mean "EMPTY" internally. The space overhead is fairly low as there is only one power-of-two sized int[] to hold the values. The set is re-hashed when adding a value that would make it >= 75% full. Consider extending and over-riding Hash(Int32) if the values might be poor hash keys; Lucene docids should be fine. The internal fields are exposed publicly to enable more efficient use at the expense of better O-O principles.

    To iterate over the integers held in this set, simply use code like this:

    SentinelIntSet set = ...
    foreach (int v in set.keys) 
    {
        if (v == set.EmptyVal)
            continue;
        //use v...
    }

    NOTE: This was SentinelIntSet in Lucene

    This is a Lucene.NET INTERNAL API, use at your own risk
    Inheritance
    System.Object
    SentinelInt32Set
    Namespace: Lucene.Net.Util
    Assembly: Lucene.Net.dll
    Syntax
    public class SentinelInt32Set : object

    Constructors

    | Improve this Doc View Source

    SentinelInt32Set(Int32, Int32)

    Declaration
    public SentinelInt32Set(int size, int emptyVal)
    Parameters
    Type Name Description
    System.Int32 size

    The minimum number of elements this set should be able to hold without rehashing (i.e. the slots are guaranteed not to change).

    System.Int32 emptyVal

    The integer value to use for EMPTY.

    Properties

    | Improve this Doc View Source

    Count

    The number of integers in this set.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    EmptyVal

    Declaration
    public int EmptyVal { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Keys

    A power-of-2 over-sized array holding the integers in the set along with empty values.

    Declaration
    public int[] Keys { get; set; }
    Property Value
    Type Description
    System.Int32[]
    | Improve this Doc View Source

    RehashCount

    The count at which a rehash should be done.

    Declaration
    public int RehashCount { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    Clear()

    Declaration
    public virtual void Clear()
    | Improve this Doc View Source

    Exists(Int32)

    Does this set contain the specified integer?

    Declaration
    public virtual bool Exists(int key)
    Parameters
    Type Name Description
    System.Int32 key
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Find(Int32)

    (internal) Returns the slot for this key, or -slot-1 if not found.

    Declaration
    public virtual int Find(int key)
    Parameters
    Type Name Description
    System.Int32 key
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    GetSlot(Int32)

    (internal) Returns the slot for this key.

    Declaration
    public virtual int GetSlot(int key)
    Parameters
    Type Name Description
    System.Int32 key
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    Hash(Int32)

    (internal) Return the hash for the key. The default implementation just returns the key, which is not appropriate for general purpose use.

    Declaration
    public virtual int Hash(int key)
    Parameters
    Type Name Description
    System.Int32 key
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    Put(Int32)

    Puts this integer (key) in the set, and returns the slot index it was added to. It rehashes if adding it would make the set more than 75% full.

    Declaration
    public virtual int Put(int key)
    Parameters
    Type Name Description
    System.Int32 key
    Returns
    Type Description
    System.Int32
    | Improve this Doc View Source

    Rehash()

    (internal) Rehashes by doubling key (int[]) and filling with the old values.

    Declaration
    public virtual void Rehash()
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)