@Override public Queue read(Kryo kryo, Input input, Class<Queue> type) { int length = input.readVarInt(true); Registration registration = kryo.readClass(input); Class cls = registration == null ? Object.class : registration.getType(); Queue queue = new Queue(length, cls); kryo.reference(queue); Class elementClass = null; Serializer serializer = null; if (genericType != null) { elementClass = genericType; serializer = kryo.getSerializer(genericType); genericType = null; } if (serializer != null) { for (int i = 0; i < length; i++) queue.addLast(kryo.readObjectOrNull(input, elementClass, serializer)); } else { for (int i = 0; i < length; i++) queue.addLast(kryo.readClassAndObject(input)); } return queue; }
public BreadthFirstIterator(GameObject root) { queue = new Queue<GameObject>(); queue.addLast(root); }