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:
Ray Greenwell
2006-02-15 01:41:14 +00:00
parent 28ac720b98
commit 1d36299e3c
13 changed files with 216 additions and 175 deletions
+45
View File
@@ -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();
}
}