Package dijjer.util

Examples of dijjer.util.BitArray


public class BitArrayTest extends TestCase {

  public static final String VERSION = "$Id: BitArrayTest.java,v 1.5 2005/04/12 13:04:15 sanity Exp $";

  public void testBitArray() {
    BitArray ba = new BitArray(100);
    for (int x = 5; x < 100; x++) {
      ba.setBit(x, true);
    }
    System.out.println(ba);
  }
View Full Code Here


      // The faster we finish the rest of this loop the better!
      if ((m1 != null) && (m1.getSpec().equals(DMT.packetTransmit))) {
        consecutiveMissingPacketReports = 0;
        // packetTransmit received
        int packetNo = m1.getInt(DMT.PACKET_NO);
        BitArray sent = (BitArray) m1.getObject(DMT.SENT);
        Buffer data = (Buffer) m1.getObject(DMT.DATA);
        _prb.addPacket(packetNo, data);
        // Remove it from rrmp if its in there
        _recentlyReportedMissingPackets.remove(new Integer(packetNo));
        // Skip checks except for 1 out of 16 packets until we get to the end
        if ((_prb.numReceived() < (_prb.getNumPackets() - 16))
          && (packetNo % 16 != 0))
          continue;
        // Check that we have what the sender thinks we have
        LinkedList missing = new LinkedList();
        for (int x = 0; x < sent.getSize(); x++) {
          if (sent.bitAt(x) && !_prb.isReceived(x)) {
            // Sender thinks we have a block which we don't, but have we already
            // re-requested it recently?
            Long resendTime = (Long) _recentlyReportedMissingPackets.get(new Integer(x));
            if ((resendTime == null) || (System.currentTimeMillis() > resendTime.longValue())) {
              // Make a note of the earliest time we should resend this,
View Full Code Here

    byte[] buf = new byte[r.nextInt() % 100];
    r.nextBytes(buf);
    written[6] = new Buffer(buf);
    written[7] = new VeryLongInteger(r.nextLong(), r.nextLong());
    written[8] = new Peer(InetAddress.getByName("google.com"), 1234);
    BitArray ba = new BitArray(r.nextInt() % 100);
    for (int x=0; x<ba.getSize(); x++) {
      ba.setBit(x, r.nextBoolean());
    }
    written[9] = ba;
    // TODO: Buffer and others, lists
    for (int x=0; x<written.length; x++) {
      Serializer.writeToDataOutputStream(written[x], dos);
View Full Code Here

TOP

Related Classes of dijjer.util.BitArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.