Some work on streaming.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3855 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,6 +1,51 @@
|
||||
package com.threerings.io {
|
||||
|
||||
import flash.util.ByteArray;
|
||||
|
||||
public class ArrayMask
|
||||
implements Streamable
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function writeObject (out :ObjectOutputStream) :void
|
||||
{
|
||||
out.writeShort(_mask.length);
|
||||
out.writeBytes(_mask);
|
||||
}
|
||||
|
||||
// documentation inherited from interface Streamable
|
||||
public function readObject (ins :ObjectInputStream) :void
|
||||
{
|
||||
_mask.length = ins.readShort();
|
||||
ins.readBytes(_mask, 0, _mask.length);
|
||||
}
|
||||
|
||||
/** The array mask. */
|
||||
protected var _mask :ByteArray = new ByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user