Added support for marshalling oid lists.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@147 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-08-02 05:09:21 +00:00
parent 499646fe94
commit 59ad4a7955
2 changed files with 61 additions and 1 deletions
@@ -1,8 +1,12 @@
//
// $Id: OidList.java,v 1.1 2001/07/21 01:06:48 mdb Exp $
// $Id: OidList.java,v 1.2 2001/08/02 05:09:21 mdb Exp $
package com.threerings.cocktail.cher.dobj;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
/**
* An oid list is used to store lists of object ids. The list will not
* allow duplicate ids. This class is not synchronized, with the
@@ -128,6 +132,25 @@ public class OidList
_oids = oids;
}
public void writeTo (DataOutputStream out)
throws IOException
{
out.writeInt(_size);
for (int i = 0; i < _size; i++) {
out.writeInt(_oids[i]);
}
}
public void readFrom (DataInputStream in)
throws IOException
{
_size = in.readInt();
_oids = new int[Math.max(DEFAULT_SIZE, _size*2)];
for (int i = 0; i < _size; i++) {
_oids[i] = in.readInt();
}
}
private int[] _oids;
private int _size;