Added ability to update elements in a set.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@266 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: DSet.java,v 1.1 2001/08/16 03:31:09 mdb Exp $
|
||||
// $Id: DSet.java,v 1.2 2001/08/16 03:45:43 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.cher.dobj;
|
||||
|
||||
@@ -219,6 +219,33 @@ public class DSet
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the specified element by locating an element whose key
|
||||
* matches the key of the supplied element and overwriting it. This
|
||||
* should not be called directly, instead the associated
|
||||
* <code>update{Set}()</code> method should be called on the
|
||||
* distributed object that contains the set in question.
|
||||
*
|
||||
* @return true if the element was updated, false if it was not
|
||||
* already in the set (in which case nothing is updated).
|
||||
*/
|
||||
protected boolean update (Element elem)
|
||||
{
|
||||
Object key = elem.getKey();
|
||||
|
||||
// scan the array looking for a matching element
|
||||
int elength = _elements.length;
|
||||
for (int i = 0; i < elength; i++) {
|
||||
Element el = _elements[i];
|
||||
if (el != null && el.getKey().equals(key)) {
|
||||
_elements[i] = elem;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Class _elementType;
|
||||
protected Element[] _elements;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user