com.sleepycat.je.rep.util.ldiff
Class BlockBag

java.lang.Object
  extended by com.sleepycat.je.rep.util.ldiff.BlockBag
All Implemented Interfaces:
Iterable<Block>

public class BlockBag
extends Object
implements Iterable<Block>

A bag of Blocks used during the LDiff process. Blocks are accessed by their checksum; when checksums collide, blocks are returned in insertion order.


Constructor Summary
BlockBag()
          Instantiate a new BlockBag object.
 
Method Summary
 void add(Block b)
          Adds a new Block to the bag.
 List<Block> get(long chksum)
          Returns all Blocks in the bag with a given checksum.
 Block getBlock()
           
 int getBlockIndex()
           
 Iterator<Block> iterator()
          Returns an iterator over the blocks in the bag, in insertion order.
 List<Block> remove(Block b)
          Removes the given Block, plus any blocks inserted previous to the given Block.
 List<Block> removeAll()
          Removes all blocks from the bag.
 int size()
          Returns the number of blocks in this bag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockBag

public BlockBag()
Instantiate a new BlockBag object.

Method Detail

add

public void add(Block b)
Adds a new Block to the bag.

Parameters:
b - The Block to be added.

get

public List<Block> get(long chksum)
Returns all Blocks in the bag with a given checksum.

Parameters:
chksum - The checksum to match
Returns:
A List of blocks with the given checksum, in insertion order, or null if no matching blocks were found.

iterator

public Iterator<Block> iterator()
Returns an iterator over the blocks in the bag, in insertion order.

Specified by:
iterator in interface Iterable<Block>
Returns:
an iterator over the blocks in the bag, in insertion order.

remove

public List<Block> remove(Block b)
Removes the given Block, plus any blocks inserted previous to the given Block.

Parameters:
b - The Block to remove.
Returns:
A List of all unmatched blocks, or null

removeAll

public List<Block> removeAll()
Removes all blocks from the bag.

Returns:
A list of all blocks removed, or null if the bag is already empty.

getBlockIndex

public int getBlockIndex()

getBlock

public Block getBlock()

size

public int size()
Returns the number of blocks in this bag.

Returns:
the number of blocks in the bag


Copyright (c) 2004-2010 Oracle. All rights reserved.