本文整理汇总了Java中com.google.common.collect.Queues类的典型用法代码示例。如果您正苦于以下问题:Java Queues类的具体用法?Java Queues怎么用?Java Queues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Queues类属于com.google.common.collect包,在下文中一共展示了Queues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Chunk
import com.google.common.collect.Queues; //导入依赖的package包/类
public Chunk(World worldIn, int x, int z)
{
this.storageArrays = new ExtendedBlockStorage[16];
this.blockBiomeArray = new byte[256];
this.precipitationHeightMap = new int[256];
this.updateSkylightColumns = new boolean[256];
this.chunkTileEntityMap = Maps.<BlockPos, TileEntity>newHashMap();
this.queuedLightChecks = 4096;
this.tileEntityPosQueue = Queues.<BlockPos>newConcurrentLinkedQueue();
this.entityLists = (ClassInheritanceMultiMap[])(new ClassInheritanceMultiMap[16]);
this.worldObj = worldIn;
this.xPosition = x;
this.zPosition = z;
this.heightMap = new int[256];
for (int i = 0; i < this.entityLists.length; ++i)
{
this.entityLists[i] = new ClassInheritanceMultiMap(Entity.class);
}
Arrays.fill((int[])this.precipitationHeightMap, (int) - 999);
Arrays.fill(this.blockBiomeArray, (byte) - 1);
}
示例2: FileReaderService
import com.google.common.collect.Queues; //导入依赖的package包/类
public FileReaderService(PathSet pathSet,
Charset charset,
FileInput.InitialReadPosition initialReadPosition,
FileInput input,
MessageBuilder messageBuilder,
ContentSplitter contentSplitter,
Buffer buffer,
int readerBufferSize,
long readerInterval,
FileObserver fileObserver) {
this.pathSet = pathSet;
this.initialReadPosition = initialReadPosition;
this.input = input;
this.messageBuilder = messageBuilder;
this.contentSplitter = contentSplitter;
this.buffer = buffer;
this.charset = charset;
this.readerBufferSize = readerBufferSize;
this.readerInterval = readerInterval;
this.fileObserver = fileObserver;
chunkQueue = Queues.newArrayBlockingQueue(2);
}
示例3: ParticleManager
import com.google.common.collect.Queues; //导入依赖的package包/类
public ParticleManager(World worldIn, TextureManager rendererIn)
{
this.worldObj = worldIn;
this.renderer = rendererIn;
for (int i = 0; i < 4; ++i)
{
this.fxLayers[i] = new ArrayDeque[2];
for (int j = 0; j < 2; ++j)
{
this.fxLayers[i][j] = Queues.newArrayDeque();
}
}
this.registerVanillaParticles();
}
示例4: afterPropertiesSet
import com.google.common.collect.Queues; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
auditExecutorService.submit(() -> {
while (!auditStopped.get() && !Thread.currentThread().isInterrupted()) {
List<ConsumerAudit> toAudit = Lists.newArrayList();
try {
Queues.drain(audits, toAudit, BATCH_SIZE, BATCH_TIMEOUT, BATCH_TIMEUNIT);
if (!toAudit.isEmpty()) {
consumerService.createConsumerAudits(toAudit);
}
} catch (Throwable ex) {
Tracer.logError(ex);
}
}
});
}
示例5: floodFill
import com.google.common.collect.Queues; //导入依赖的package包/类
private Set<EnumFacing> floodFill(int p_178604_1_)
{
Set<EnumFacing> set = EnumSet.<EnumFacing>noneOf(EnumFacing.class);
Queue<Integer> queue = Queues.<Integer>newArrayDeque();
queue.add(IntegerCache.getInteger(p_178604_1_));
this.bitSet.set(p_178604_1_, true);
while (!((Queue)queue).isEmpty())
{
int i = ((Integer)queue.poll()).intValue();
this.addEdges(i, set);
for (EnumFacing enumfacing : EnumFacing.values())
{
int j = this.getNeighborIndexAtFace(i, enumfacing);
if (j >= 0 && !this.bitSet.get(j))
{
this.bitSet.set(j, true);
queue.add(IntegerCache.getInteger(j));
}
}
}
return set;
}
示例6: NutchServer
import com.google.common.collect.Queues; //导入依赖的package包/类
private NutchServer() {
configManager = new ConfManagerImpl();
BlockingQueue<Runnable> runnables = Queues.newArrayBlockingQueue(JOB_CAPACITY);
NutchServerPoolExecutor executor = new NutchServerPoolExecutor(10, JOB_CAPACITY, 1, TimeUnit.HOURS, runnables);
jobManager = new JobManagerImpl(new JobFactory(), configManager, executor);
fetchNodeDb = FetchNodeDb.getInstance();
sf = new JAXRSServerFactoryBean();
BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
JAXRSBindingFactory factory = new JAXRSBindingFactory();
factory.setBus(sf.getBus());
manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);
sf.setResourceClasses(getClasses());
sf.setResourceProviders(getResourceProviders());
sf.setProvider(new JacksonJaxbJsonProvider());
}
示例7: start
import com.google.common.collect.Queues; //导入依赖的package包/类
@Override
public void start() {
if (this.encoder == null) {
addError("No encoder set for the appender named ["+ name +"].");
return;
}
try {
encoder.init(stream);
} catch (IOException ignored) {
}
EvictingQueue<String> q = EvictingQueue.create(limit);
logList = Queues.synchronizedQueue(q);
isLoggingOn = true;
super.start();
}
示例8: ConsumerBase
import com.google.common.collect.Queues; //导入依赖的package包/类
protected ConsumerBase(PulsarClientImpl client, String topic, String subscription, ConsumerConfiguration conf,
int receiverQueueSize, ExecutorService listenerExecutor, CompletableFuture<Consumer> subscribeFuture) {
super(client, topic, new Backoff(100, TimeUnit.MILLISECONDS, 60, TimeUnit.SECONDS, 0 , TimeUnit.MILLISECONDS));
this.maxReceiverQueueSize = receiverQueueSize;
this.subscription = subscription;
this.conf = conf;
this.consumerName = conf.getConsumerName() == null ? ConsumerName.generateRandomName() : conf.getConsumerName();
this.subscribeFuture = subscribeFuture;
this.listener = conf.getMessageListener();
if (receiverQueueSize <= 1) {
this.incomingMessages = Queues.newArrayBlockingQueue(1);
} else {
this.incomingMessages = new GrowableArrayBlockingQueue<>();
}
this.listenerExecutor = listenerExecutor;
this.pendingReceives = Queues.newConcurrentLinkedQueue();
}
示例9: ManagedLedgerImpl
import com.google.common.collect.Queues; //导入依赖的package包/类
public ManagedLedgerImpl(ManagedLedgerFactoryImpl factory, BookKeeper bookKeeper, MetaStore store,
ManagedLedgerConfig config, ScheduledExecutorService scheduledExecutor, OrderedSafeExecutor orderedExecutor,
final String name) {
this.factory = factory;
this.bookKeeper = bookKeeper;
this.config = config;
this.store = store;
this.name = name;
this.scheduledExecutor = scheduledExecutor;
this.executor = orderedExecutor;
TOTAL_SIZE_UPDATER.set(this, 0);
NUMBER_OF_ENTRIES_UPDATER.set(this, 0);
ENTRIES_ADDED_COUNTER_UPDATER.set(this, 0);
STATE_UPDATER.set(this, State.None);
this.ledgersStat = null;
this.mbean = new ManagedLedgerMBeanImpl(this);
this.entryCache = factory.getEntryCacheManager().getEntryCache(this);
this.waitingCursors = Queues.newConcurrentLinkedQueue();
this.uninitializedCursors = Maps.newHashMap();
this.updateCursorRateLimit = RateLimiter.create(1);
// Get the next rollover time. Add a random value upto 5% to avoid rollover multiple ledgers at the same time
this.maximumRolloverTimeMs = (long) (config.getMaximumRolloverTimeMs() * (1 + random.nextDouble() * 5 / 100.0));
}
示例10: bfsLists
import com.google.common.collect.Queues; //导入依赖的package包/类
/**
* Do a breadth-first search over the given collection of lists, applying the supplied function
* to each item in the list. If the function returns an explicit true (not null or false)
* the search will abort.
*
* @param toTraverse the lists to traverse (breadth-first)
* @param toApply the function to apply (if it returns true the search will abort)
* @return the number of lists visited (inclusive)
*/
public static int bfsLists(Collection<WFList> toTraverse, Function<WFList, Boolean> toApply) {
if (toTraverse == null) return 0;
int numVisited = 0;
Queue<WFList> visitQueue = Queues.newArrayDeque(toTraverse);
while (!visitQueue.isEmpty()) {
numVisited++;
WFList cur = visitQueue.remove();
Boolean abort = toApply.apply(cur);
if (abort != null && abort.equals(true)) {
break;
}
if (cur.getChildren() != null) {
visitQueue.addAll(cur.getChildren());
}
}
return numVisited;
}
示例11: pathExistsDirectional
import com.google.common.collect.Queues; //导入依赖的package包/类
/**
* Route Between Nodes: Find whether there is a path between two nodes (A->B) in a directed graph.
*
* Assumptions:
*
* Time complexity: O(n)
* Space complexity: O(n)
*
* Notes: Simple breadth first search.
*/
public static boolean pathExistsDirectional(IntNode a, IntNode b, IntGraph graph) {
if (a == b) {
return true;
}
Queue<IntNode> queue = Queues.newArrayDeque();
Set<IntNode> visited = Sets.newHashSet();
queue.add(a);
visited.add(a);
while (!queue.isEmpty()) {
IntNode next = queue.remove();
for (Node<Integer> adjacent : next.getAdjacent()) {
if (adjacent == b) {
return true;
} else if (visited.add((IntNode) adjacent)) {
queue.add((IntNode) adjacent);
}
}
}
return false;
}
示例12: pathExistsBidirectional
import com.google.common.collect.Queues; //导入依赖的package包/类
/**
* Route Between Nodes: Modified - Find whether there is a path between two nodes (A->B) in a bidirectional graph.
*
* Assumptions:
*
* Time complexity: O(n) where n is numer of nodes
* Space complexity: O(n)
*/
public static boolean pathExistsBidirectional(IntNode a, IntNode b) {
// BFS on both nodes at the same time
Queue<IntNode> queueA = Queues.newArrayDeque();
Queue<IntNode> queueB = Queues.newArrayDeque();
Set<IntNode> visitedA = Sets.newHashSet();
Set<IntNode> visitedB = Sets.newHashSet();
visitedA.add(a);
visitedB.add(b);
queueA.add(a);
queueB.add(b);
while (!queueA.isEmpty() && !queueB.isEmpty()) {
if (pathExistsBidirectionalHelper(queueA, visitedA, visitedB)) {
return true;
}
if (pathExistsBidirectionalHelper(queueB, visitedB, visitedA)) {
return true;
}
}
return false;
}
示例13: PubSubClient
import com.google.common.collect.Queues; //导入依赖的package包/类
PubSubClient(String hostname, int port, int maxPendingMessages) throws IOException {
this.hostname = hostname;
this.port = port;
this.maxPendingMessages = maxPendingMessages;
if (maxPendingMessages <= 0) {
this.pending = Queues.newLinkedBlockingDeque();
} else {
this.pending = Queues.newLinkedBlockingDeque(maxPendingMessages);
}
this.selector = Selector.open();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
close();
}
});
}
示例14: addFunctions
import com.google.common.collect.Queues; //导入依赖的package包/类
/**
* Adds all function names and signatures to passed jar,
* adds all function names, their signatures and holders to {@link #functions}.
*
* @param jar jar where function to be added
* @param newFunctions collection of function holders, each contains function name, signature and holder.
*/
private void addFunctions(Map<String, Queue<String>> jar, List<FunctionHolder> newFunctions) {
for (FunctionHolder function : newFunctions) {
final String functionName = function.getName();
Queue<String> jarFunctions = jar.get(functionName);
if (jarFunctions == null) {
jarFunctions = Queues.newConcurrentLinkedQueue();;
jar.put(functionName, jarFunctions);
}
final String functionSignature = function.getSignature();
jarFunctions.add(functionSignature);
Map<String, DrillFuncHolder> signatures = functions.get(functionName);
if (signatures == null) {
signatures = Maps.newConcurrentMap();
functions.put(functionName, signatures);
}
signatures.put(functionSignature, function.getHolder());
}
}
示例15: schemaPathToFieldPath
import com.google.common.collect.Queues; //导入依赖的package包/类
/**
* Returns {@link FieldPath} equivalent of the specified {@link SchemaPath}.
*
* @param schemaPath {@link SchemaPath} instance that should be converted
* @return {@link FieldPath} equivalent of the specified {@link SchemaPath}.
*/
public static FieldPath schemaPathToFieldPath(SchemaPath schemaPath) {
Deque<PathSegment> pathSegments = Queues.newArrayDeque();
PathSegment pathSegment = schemaPath.getRootSegment();
while (pathSegment != null) {
pathSegments.push(pathSegment);
pathSegment = pathSegment.getChild();
}
FieldSegment child = null;
while (!pathSegments.isEmpty()) {
pathSegment = pathSegments.pop();
if (pathSegment.isNamed()) {
child = new FieldSegment.NameSegment(((PathSegment.NameSegment) pathSegment).getPath(), child, false);
} else {
child = new FieldSegment.IndexSegment(String.valueOf(((PathSegment.ArraySegment) pathSegment).getIndex()), child);
}
}
return new FieldPath((FieldSegment.NameSegment) child);
}