Files
narya/src/as/com/threerings/io/ArrayMask.as
T
Ray Greenwell e100ef4faf Updated to match API changes in Beta3.
InvocationRegistration had a constructor called Registration. I wonder if
that was causing the compile error with beta2.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4104 542714f4-19e9-0310-aa3c-eee0fc999fb1
2006-05-09 23:03:47 +00:00

50 lines
1.1 KiB
ActionScript

package com.threerings.io {
import flash.utils.ByteArray;
public class ArrayMask
{
public function ArrayMask (length :int = 0)
{
var mlength :int = length / 8;
if (length % 8 != 0) {
mlength++;
}
_mask.length = mlength;
}
/**
* Set the specified index as containing a non-null element in the
* array we're representing.
*/
public function setBit (index :int) :void
{
_mask[index/8] |= (1 << (index % 8));
}
/**
* Is the specified array element non-null?
*/
public function isSet (index :int) :Boolean
{
return (_mask[index/8] & (1 << (index % 8))) != 0;
}
public function writeTo (out :ObjectOutputStream) :void
{
out.writeShort(_mask.length);
out.writeBytes(_mask);
}
// documentation inherited from interface Streamable
public function readFrom (ins :ObjectInputStream) :void
{
_mask.length = ins.readShort();
ins.readBytes(_mask, 0, _mask.length);
}
/** The array mask. */
protected var _mask :ByteArray = new ByteArray();
}
}