Methods Summary |
---|
public com.aelitis.azureus.core.peermanager.piecepicker.util.BitFlags | and(com.aelitis.azureus.core.peermanager.piecepicker.util.BitFlags other)Experimental. Returns a new BitFlags with flags set as the logical AND of both BitFlags.
The length of both must be the same.
final BitFlags result =new BitFlags(flags.length);
if (this.nbSet >0 &&other.nbSet >0)
{
// setup outer union bounds
int i =this.start >other.start ?this.start :other.start;
final int endI =this.end <other.end ?this.end :other.end;
// find the first common set bit
for (; i <=endI; i++)
{
if (this.flags[i] &&other.flags[i])
{
result.flags[i] =true;
result.nbSet++;
result.start =i;
break;
}
}
// find any remaining common bits
for (; i <=endI; i++)
{
if (this.flags[i] &&other.flags[i])
{
result.flags[i] =true;
result.nbSet++;
result.end =i;
}
}
if (result.end <result.start)
result.end =result.start;
}
return result;
|
public void | clear()
Arrays.fill(flags, false);
start =flags.length;
end =0;
nbSet =0;
|
public java.lang.Object | clone()
return new BitFlags(this);
|
public boolean | equals(java.lang.Object o)
if (o ==null ||!(o instanceof BitFlags))
return false;
final BitFlags other =(BitFlags) o;
if (this.start !=other.start)
return false;
if (this.end !=other.end)
return false;
if (this.nbSet !=other.nbSet)
return false;
if (this.flags ==null &&other.flags ==null)
return true;
if (this.flags ==null ||other.flags ==null)
return false;
if (this.flags.length !=other.flags.length)
return false;
for (int i =0; i <this.flags.length; i++)
{
if (this.flags[i] ^ other.flags[i])
return false;
}
return true;
|
public int | hashCode()
int result =HashCodeUtils.hashMore(0, flags);
result =HashCodeUtils.hashMore(result, nbSet);
result =HashCodeUtils.hashMore(result, end);
return HashCodeUtils.hashMore(result, start);
|
public void | set(int i)for setting a flag that is not known to be the first or last, or not
if (!flags[i])
{
flags[i] =true;
nbSet++;
if (start >i)
start =i;
if (end <i)
end =i;
}
|
public void | setAll()
start =0;
end =flags.length -1;
Arrays.fill(flags, start, end, true);
nbSet =flags.length;
|
public void | setEnd(int i)this is for setting a flag that is already known to be the last true flag
flags[i] =true;
nbSet++;
end =i;
|
public void | setOnly(int i)clears the array then sets the given flag
if (start <flags.length)
Arrays.fill(flags, start, end, false);
nbSet =1;
start =i;
end =i;
flags[i] =true;
|
public void | setStart(int i)for setting a flag that is already known to be the first true flag
flags[i] =true;
nbSet++;
start =i;
|
public int | size()You can read flags.length instead (but please don't modify it)
return flags.length;
|