Ian
By: a guest | Apr 16th, 2008 | Syntax:
Java | Size: 1.07 KB | Hits: 138 | Expires: Never
public class LargeSerializableConcurrentSkipListMap<K, V> extends
ConcurrentSkipListMap<K, V> {
private static final long serialVersionUID = -1525292268623732635L;
for (Map.
Entry<K, V
> e
: this.
entrySet()) {
stream.writeObject(e.getKey());
stream.writeObject(e.getValue());
}
// We do it like this because items can be added and removed
// during serialization and an "end of object" indicator is more
// robust given this
stream.writeObject(new EndObject());
stream.writeObject(new EndObject());
}
@SuppressWarnings("unchecked")
while (true) {
Object k
= stream.
readObject();
Object v
= stream.
readObject();
if ((k instanceof EndObject) && (v instanceof EndObject)) {
break;
}
this.put((K) k, (V) v);
}
}
private static final long serialVersionUID = -5347717251973679220L;
}
}