example.mspastry
Class LeafSet

public class LeafSet
implements java.lang.Cloneable

Title: MSPASTRY

Description: MsPastry implementation for PeerSim

Copyright: Copyright (c) 2007

Company: The Patry Group

Version:
1.0
Author:
Elisa Bisoffi, Manuel Cortella
Field Detail

left

private java.math.BigInteger[] left
ordered array of the nodeIds inserted closest to and lower than the nodeId

right

private java.math.BigInteger[] right
ordered array of the nodeIds inserted closest to and higher than the nodeId

size

private int size
total size of the leaf set

hsize

private int hsize
size of both left and right part of the leaf set

nodeId

java.math.BigInteger nodeId
pivot nodeId

Method Detail

indexOf

private int indexOf(java.math.BigInteger keyToFind)
returns EMPTY if the leaf set does not contains the specified Key. returns the position in one of the two arrays of the keyToFind otherwise. to establish if the keyToFind is located in left or in right array, simply check if newNode > keyToFind (right) or not (left)
Parameters:
keyToFind - long
Returns:
int

shift

private void shift(int pos)
effettua lo scorrimento di un array di una posizione, a partire dall'elemento di indice pos (compreso).
Parameters:
a - long[]
sz - int
n - long

correctRightPosition

private int correctRightPosition(java.math.BigInteger n)
Empty indicates: DO NOT (RE)INSERT!!!
Parameters:
n - long
Returns:
int

correctLeftPosition

private int correctLeftPosition(java.math.BigInteger n)
Empty indicates: DO NOT (RE)INSERT!!!
Parameters:
n - long
Returns:
int

push

public void push(java.math.BigInteger newNode)
push into the leafset the specified node, by according the properties specified by the mspastry protocol
Parameters:
newNode - long

main

public static void main(java.lang.String[] args)
Test
Parameters:
args - String[]