本文整理汇总了Java中com.google.common.collect.UnmodifiableIterator类的典型用法代码示例。如果您正苦于以下问题:Java UnmodifiableIterator类的具体用法?Java UnmodifiableIterator怎么用?Java UnmodifiableIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnmodifiableIterator类属于com.google.common.collect包,在下文中一共展示了UnmodifiableIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addListener
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public synchronized void addListener ( final EventListener eventListener )
{
this.listeners.add ( eventListener );
final UnmodifiableIterator<List<Event>> it = Iterators.partition ( AbstractEventQueryImpl.this.events.iterator (), chunkSize );
while ( it.hasNext () )
{
final List<org.eclipse.scada.ae.Event> chunk = it.next ();
this.executor.execute ( new Runnable () {
@Override
public void run ()
{
eventListener.handleEvent ( chunk );
}
} );
}
}
示例2: iterator
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public UnmodifiableIterator<E> iterator() {
final Iterator<? extends Entry<E, ?>> entries = outEdgeToNode.entrySet().iterator();
return new AbstractIterator<E>() {
@Override
protected E computeNext() {
while (entries.hasNext()) {
Entry<E, ?> entry = entries.next();
if (targetNode.equals(entry.getValue())) {
return entry.getKey();
}
}
return endOfData();
}
};
}
示例3: getConcreteIndexAndAliasMetaDatas
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
/**
* Returns the unique alias metadata per concrete index.
*
* (note that although alias can point to the same concrete indices, each alias reference may have its own routing
* and filters)
*/
public Iterable<Tuple<String, AliasMetaData>> getConcreteIndexAndAliasMetaDatas() {
return new Iterable<Tuple<String, AliasMetaData>>() {
@Override
public Iterator<Tuple<String, AliasMetaData>> iterator() {
return new UnmodifiableIterator<Tuple<String,AliasMetaData>>() {
int index = 0;
@Override
public boolean hasNext() {
return index < referenceIndexMetaDatas.size();
}
@Override
public Tuple<String, AliasMetaData> next() {
IndexMetaData indexMetaData = referenceIndexMetaDatas.get(index++);
return new Tuple<>(indexMetaData.getIndex(), indexMetaData.getAliases().get(aliasName));
}
};
}
};
}
示例4: iterator
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public Iterator<InetSocketAddress> iterator() {
return new UnmodifiableIterator<InetSocketAddress>() {
private final Iterator<Map.Entry<InetAddress,
Integer>> it = addrs.entries().iterator();
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
public InetSocketAddress next() {
Map.Entry<InetAddress, Integer> e = it.next();
return new InetSocketAddress(e.getKey(), e.getValue());
}
};
}
示例5: edges
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
/**
* An implementation of {@link BaseGraph#edges()} defined in terms of {@link #nodes()} and {@link
* #successors(Object)}.
*/
@Override
public Set<EndpointPair<N>> edges() {
return new AbstractSet<EndpointPair<N>>() {
@Override
public UnmodifiableIterator<EndpointPair<N>> iterator() {
return EndpointPairIterator.of(AbstractBaseGraph.this);
}
@Override
public int size() {
return Ints.saturatedCast(edgeCount());
}
@Override
public boolean contains(@Nullable Object obj) {
if (!(obj instanceof EndpointPair)) {
return false;
}
EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
return isDirected() == endpointPair.isOrdered()
&& nodes().contains(endpointPair.nodeU())
&& successors(endpointPair.nodeU()).contains(endpointPair.nodeV());
}
};
}
示例6: writeBlockState
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
/**
* Writes the given blockstate to the given tag.
*
* @param tag The tag to write to
* @param state The blockstate to be written
*/
public static NBTTagCompound writeBlockState(NBTTagCompound tag, IBlockState state)
{
tag.setString("Name", ((ResourceLocation)Block.REGISTRY.getNameForObject(state.getBlock())).toString());
if (!state.getProperties().isEmpty())
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
UnmodifiableIterator unmodifiableiterator = state.getProperties().entrySet().iterator();
while (unmodifiableiterator.hasNext())
{
Entry < IProperty<?>, Comparable<? >> entry = (Entry)unmodifiableiterator.next();
IProperty<?> iproperty = (IProperty)entry.getKey();
nbttagcompound.setString(iproperty.getName(), getName(iproperty, (Comparable)entry.getValue()));
}
tag.setTag("Properties", nbttagcompound);
}
return tag;
}
示例7: hasInstantEffect
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
public boolean hasInstantEffect()
{
if (!this.effects.isEmpty())
{
UnmodifiableIterator unmodifiableiterator = this.effects.iterator();
while (unmodifiableiterator.hasNext())
{
PotionEffect potioneffect = (PotionEffect)unmodifiableiterator.next();
if (potioneffect.getPotion().isInstant())
{
return true;
}
}
}
return false;
}
示例8: apply
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public Optional<TRSRTransformation> apply(final Optional<? extends IModelPart> part)
{
if (part.isPresent())
{
final UnmodifiableIterator<String> parts = Models.getParts(part.get());
if (parts.hasNext())
{
final String name = parts.next();
if (!parts.hasNext() && this.blacklist && this.parts.contains(name)
|| !this.blacklist && !this.parts.contains(name))
return this.value;
}
}
return Optional.empty();
}
示例9: testListTablesRestricted
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Test
public void testListTablesRestricted() {
final TableOptions options = new TableOptionsBuilder().setPlacement("my:placement").build();
final ImmutableMap<String, Object> template = ImmutableMap.<String, Object>of("key", "value1");
final TableAvailability availability = new TableAvailability("my:placement", false);
final DefaultTable a1 = new DefaultTable("a-table-1", options, template, availability);
final DefaultTable a2 = new DefaultTable("a-table-2", options, template, availability);
final DefaultTable b1 = new DefaultTable("b-table-1", options, template, availability);
final DefaultTable b2 = new DefaultTable("b-table-2", options, template, availability);
final DefaultTable a3 = new DefaultTable("a-table-3", options, template, availability);
final ImmutableList<Table> tables = ImmutableList.of(a1, a2, b1, b2, a3);
final UnmodifiableIterator<Table> iterator = tables.iterator();
//noinspection unchecked
when(_server.listTables(null, Long.MAX_VALUE)).thenAnswer(invocation -> iterator);
{
final Iterator<Table> tableIterator = sorClient(APIKEY_READ_TABLES_A).listTables(null, 3);
final ImmutableList<Table> result = ImmutableList.copyOf(tableIterator);
assertEquals(ImmutableList.<Table>of(a1, a2, a3), result);
}
verify(_server, times(1)).listTables(null, Long.MAX_VALUE);
}
示例10: apply
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
{
if(part.isPresent())
{
// This whole thing is subject to change, but should do for now.
UnmodifiableIterator<String> parts = Models.getParts(part.get());
if(parts.hasNext())
{
String name = parts.next();
// only interested in the root level
if(!parts.hasNext() && hidden.contains(name))
{
return value;
}
}
}
return Optional.absent();
}
示例11: callable
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Provides
Iterable<Callable<Integer>> callable() {
return new Iterable<Callable<Integer>>() {
@Override
public Iterator<Callable<Integer>> iterator() {
return new UnmodifiableIterator<Callable<Integer>>() {
@Override
public boolean hasNext() {
return true;
}
@Override
public Callable<Integer> next() {
return new Callable<Integer>() {
@Override
public Integer call() throws Exception {
TimeMeasure.millis(3).sleep();
return 1;
}
};
}
};
}
};
}
示例12: getItemModels
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
protected Iterator<IModel<T>> getItemModels(final long offset, final long size) {
final List<T> list = getModelObject();
if (list == null) {
return Collections.emptyIterator();
}
return new UnmodifiableIterator<IModel<T>>() {
private int index = (int) offset;
private final int end = (int) (offset + size);
@Override
public boolean hasNext() {
return index < end && index < internalGetItemCount();
}
@Override
public IModel<T> next() {
return newItemModel(index++);
}
};
}
示例13: getHighestFiveCardHand
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public IHand getHighestFiveCardHand()
{
// if(cards.size() < 5)
// {
// return this;
// }
// return new Hand(cards.asList().reverse().subList(0,5));
UnmodifiableIterator iter = cards.iterator();
int offset = cards.size() - 5;
while(offset-- > 0)
{
iter.next();
}
return new SortedHand(cards.tailSet((Card)iter.next()) );
}
示例14: getHighestFiveCardHand
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public IHand getHighestFiveCardHand() {
if(cards.size() < 5)
{
return this;
}
ImmutableSortedSet<Card> sortedCards = cardsSorted();
UnmodifiableIterator iter = sortedCards.iterator();
int offset = sortedCards.size() - 5;
while(offset-- > 0)
{
iter.next();
}
return new SortedHand(sortedCards.tailSet((Card)iter.next()) );
}
示例15: iterator
import com.google.common.collect.UnmodifiableIterator; //导入依赖的package包/类
@Override
public Iterator<KAFDocument> iterator() {
return new UnmodifiableIterator<KAFDocument>() {
private int index = 0;
@Override
public boolean hasNext() {
return this.index < Corpus.this.files.length;
}
@Override
public KAFDocument next() {
return get(this.index++);
}
};
}