本文整理汇总了Java中org.andengine.util.adt.list.IList类的典型用法代码示例。如果您正苦于以下问题:Java IList类的具体用法?Java IList怎么用?Java IList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IList类属于org.andengine.util.adt.list包,在下文中一共展示了IList类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: peek
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
public T peek() {
final ReentrantLock lock = this.mLock;
lock.lock();
try {
if (this.mSize == 0) {
return null;
} else {
final SparseArray<IList<T>> queues = this.mQueues;
final int queueCount = queues.size();
for (int i = 0; i < queueCount; i++) {
final IList<T> queue = this.mQueues.valueAt(i);
if (queue.size() > 0) {
return queue.get(0);
}
}
return null;
}
} finally {
lock.unlock();
}
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:23,代码来源:PriorityBlockingAggregatorQueue.java
示例2: offer
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
/**
* Inserts the specified element at the tail of this queue with the given priority, if it is possible without exceeding the capacity of the queue with the given priority.
*
* @throws IllegalArgumentException if pItem is <code>null</code>
* @return <code>true</code> if the
*/
public boolean offer(final int pPriority, final T pItem) throws IllegalArgumentException {
if (pItem == null) {
throw new IllegalArgumentException("pItem must not be null.");
}
final ReentrantLock lock = this.mLock;
lock.lock();
try {
final IList<T> queue = this.mQueues.get(pPriority);
if (queue == null) {
throw new IllegalArgumentException("No queue found for pPriority: '" + pPriority + "'.");
}
final int queueCapacity = this.mQueueCapacities.get(pPriority);
if (queue.size() == queueCapacity) {
return false;
} else {
insert(pPriority, pItem);
return true;
}
} finally {
lock.unlock();
}
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:32,代码来源:PriorityBlockingAggregatorQueue.java
示例3: clear
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
public void clear() {
final ReentrantLock lock = this.mLock;
lock.lock();
try {
if (this.mSize > 0) {
final SparseArray<IList<T>> queues = this.mQueues;
final int queueCount = queues.size();
for (int i = 0; i < queueCount; i++) {
final int priority = this.mQueues.keyAt(i);
final IList<T> queue = this.mQueues.valueAt(i);
queue.clear();
final Condition notFullCondition = this.mNotFullConditions.get(priority);
notFullCondition.signal();
}
this.mSize = 0;
}
} finally {
lock.unlock();
}
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:24,代码来源:PriorityBlockingAggregatorQueue.java
示例4: toString
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
@Override
public String toString() {
final ReentrantLock lock = this.mLock;
lock.lock();
try {
final StringBuilder stringBuilder = new StringBuilder();
if (this.mQueues.size() > 0) {
final SparseArray<IList<T>> queues = this.mQueues;
final SparseIntArray queueCapacities = this.mQueueCapacities;
stringBuilder.append(" [\n");
final int queueCount = queues.size();
for (int i = 0; i < queueCount; i++) {
final int priority = queues.keyAt(i);
final IList<T> queue = queues.valueAt(i);
final int queueCapacity = queueCapacities.valueAt(i);
final int queueSize = queue.size();
stringBuilder.append("\tPriority: ").append(priority).append(" (Capacity: ").append(queueSize).append('/').append(queueCapacity).append("): ");
stringBuilder.append(queue.toString());
if (i < (queueCount - 1)) {
stringBuilder.append(',');
}
stringBuilder.append('\n');
}
stringBuilder.append(']');
}
return stringBuilder.toString();
} finally {
lock.unlock();
}
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:39,代码来源:PriorityBlockingAggregatorQueue.java
示例5: insert
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
private void insert(final int pPrority, final T pItem) { // TODO Causes another (potentially unnecessary) lookup for the queue
final IList<T> queue = this.mQueues.get(pPrority);
queue.add(pItem);
this.mSize++;
this.mNotEmptyCondition.signal();
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:8,代码来源:PriorityBlockingAggregatorQueue.java
示例6: extract
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
private T extract() {
final SparseArray<IList<T>> queues = this.mQueues;
final int queueCount = queues.size();
for (int i = 0; i < queueCount; i++) {
final IList<T> queue = this.mQueues.valueAt(i);
if (queue.size() > 0) {
final int priority = this.mQueues.keyAt(i);
return this.extract(priority);
}
}
return null;
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:13,代码来源:PriorityBlockingAggregatorQueue.java
示例7: put
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
/**
* Inserts the specified element at the tail of this queue with the given priority, waiting for space to become available if the queue is full.
*
* @throws IllegalArgumentException if pItem is <code>null</code>
* @throws InterruptedException
*/
public void put(final int pPriority, final T pItem) throws IllegalArgumentException, InterruptedException {
if (pItem == null) {
throw new IllegalArgumentException("pItem must not be null.");
}
final ReentrantLock lock = this.mLock;
final Condition notFullCondition = this.mNotFullConditions.get(pPriority);
lock.lockInterruptibly();
try {
final IList<T> queue = this.mQueues.get(pPriority);
if (queue == null) {
throw new IllegalArgumentException("No queue found for pPriority: '" + pPriority + "'.");
}
final int queueCapacity = this.mQueueCapacities.get(pPriority);
try {
while (queue.size() == queueCapacity) {
notFullCondition.await();
}
} catch (final InterruptedException e) {
/* Propagate to non-interrupted thread. */
notFullCondition.signal();
throw e;
}
insert(pPriority, pItem);
} finally {
lock.unlock();
}
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:37,代码来源:PriorityBlockingAggregatorQueue.java
示例8: sort
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
@Override
public void sort(final IList<T> pList, final int pStart, final int pEnd, final Comparator<T> pComparator) {
for (int i = pStart + 1; i < pEnd; i++) {
final T current = pList.get(i);
T prev = pList.get(i - 1);
if (pComparator.compare(current, prev) < 0) {
int j = i;
do {
pList.set(j--, prev);
} while (j > pStart && pComparator.compare(current, prev = pList.get(j - 1)) < 0);
pList.set(j, current);
}
}
return;
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:16,代码来源:InsertionSorter.java
示例9: sort
import org.andengine.util.adt.list.IList; //导入依赖的package包/类
@Override
public void sort(final IList<T> pList, final int pStart, final int pEnd, final Comparator<T> pComparator) {
for(int i = pStart + 1; i < pEnd; i++) {
final T current = pList.get(i);
T prev = pList.get(i - 1);
if(pComparator.compare(current, prev) < 0) {
int j = i;
do {
pList.set(j--, prev);
} while(j > pStart && pComparator.compare(current, prev = pList.get(j - 1)) < 0);
pList.set(j, current);
}
}
return;
}
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:16,代码来源:InsertionSorter.java
注:本文中的org.andengine.util.adt.list.IList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论