C# Class Utils.tree.FenwickTree

Afficher le fichier Open project: eric7237cire/CodeJam

Méthodes publiques

Méthode Description
AdjustIndexBy ( int index, int valueToAdd, int mod = int.MaxValue ) : void
FenwickTree ( int n ) : System
SumFromTo ( int left, int right, int mod = int.MaxValue ) : int
SumTo ( int ft, int right, int mod = int.MaxValue ) : int

Returns cumulative sum from [1, right]

findAnyIndexWithFreq ( int cumFre ) : int
findLowestIndexWithFreq ( int cumFre ) : int

Private Methods

Méthode Description
SubtractLeastSignificantBit ( int S ) : int
msb32 ( int x ) : int

Given a binary integer value x, the most significant 1 bit (highest numbered element of a bit set) can be computed using a SWAR algorithm that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with the same most significant 1 as x, but all 1's below it. Bitwise AND of the original value with the complement of the "folded" value shifted down by one yields the most significant bit. For a 32-bit value:

Method Details

AdjustIndexBy() public méthode

public AdjustIndexBy ( int index, int valueToAdd, int mod = int.MaxValue ) : void
index int
valueToAdd int
mod int
Résultat void

FenwickTree() public méthode

public FenwickTree ( int n ) : System
n int
Résultat System

SumFromTo() public méthode

public SumFromTo ( int left, int right, int mod = int.MaxValue ) : int
left int
right int
mod int
Résultat int

SumTo() public static méthode

Returns cumulative sum from [1, right]
public static SumTo ( int ft, int right, int mod = int.MaxValue ) : int
ft int
right int
mod int
Résultat int

findAnyIndexWithFreq() public méthode

public findAnyIndexWithFreq ( int cumFre ) : int
cumFre int
Résultat int

findLowestIndexWithFreq() public méthode

public findLowestIndexWithFreq ( int cumFre ) : int
cumFre int
Résultat int