LimeWire collection component api

org.limewire.collection
Class NotView

java.lang.Object
  extended by org.limewire.collection.NotView
All Implemented Interfaces:
BitField

public class NotView
extends java.lang.Object
implements BitField

Provides a not view for a BitField. See not for more information.

    void sampleCodeNotView(){
        BitSet bs1 = new BitSet();
        bs1.set(0);
        bs1.set(1);

        BitField bf1 = new BitFieldSet(bs1, 5);

        printBitField(bf1, "bf1");

        NotView nv = new NotView(bf1);

        printBitField(nv, " nv");
    }

    void printBitField(BitField bf, String bfName){
        System.out.print(bfName + ": ");
        for(int i = 0; i < bf.maxSize(); i++){
            int j = 0;
            if(bf.get(i))
                j = 1;          
            System.out.print(j);
        }
        System.out.println(""); 
    }

    Output:
        bf1: 11000
         nv: 00111


Constructor Summary
NotView(BitField bf)
           
 
Method Summary
 int cardinality()
           
 boolean get(int i)
           
 int maxSize()
           
 int nextClearBit(int i)
           
 int nextSetBit(int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotView

public NotView(BitField bf)
Method Detail

cardinality

public int cardinality()
Specified by:
cardinality in interface BitField

get

public boolean get(int i)
Specified by:
get in interface BitField

maxSize

public int maxSize()
Specified by:
maxSize in interface BitField

nextClearBit

public int nextClearBit(int i)
Specified by:
nextClearBit in interface BitField

nextSetBit

public int nextSetBit(int i)
Specified by:
nextSetBit in interface BitField
Returns:
index of next set bit from index i or -1 if there is no bit left

LimeWire collection component api

Copyright © 2009 Lime Wire LLC. All Rights Reserved.