All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.mais_h.mathsync.SerializedItems Maven / Gradle / Ivy

The newest version!
package eu.mais_h.mathsync;

import java.util.Iterator;
import java.util.Set;

import eu.mais_h.mathsync.serialize.Serializer;

class SerializedItems implements Iterable {

  private final Set items;
  private final Serializer serializer;

  SerializedItems(Set items, Serializer serializer) {
    this.items = items;
    this.serializer = serializer;
  }

  int size() {
    return items.size();
  }

  @Override
  public Iterator iterator() {
    return new SerializedIterator();
  }

  private class SerializedIterator implements Iterator {

    private final Iterator itemsIterator = items.iterator();

    @Override
    public boolean hasNext() {
      return itemsIterator.hasNext();
    }

    @Override
    public byte[] next() {
      return serializer.serialize(itemsIterator.next());
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy