mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
java highlighting tests moved to community
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
/** @noinspection UnusedDeclaration*/
|
||||
class LimitedPool<T> {
|
||||
private int capacity;
|
||||
private final ObjectFactory<T> factory;
|
||||
private Object[] storage;
|
||||
private int index = 0;
|
||||
|
||||
public LimitedPool(final int capacity, ObjectFactory<T> factory) {
|
||||
this.capacity = capacity;
|
||||
this.factory = factory;
|
||||
storage = new Object[capacity];
|
||||
}
|
||||
|
||||
interface ObjectFactory<T> {
|
||||
T create();
|
||||
void cleanup(T t);
|
||||
}
|
||||
|
||||
public T alloc() {
|
||||
if (index >= capacity) return factory.create();
|
||||
|
||||
if (storage[index] == null) {
|
||||
storage[index] = factory.create();
|
||||
}
|
||||
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object[]', required: 'T'">return storage;</error>
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user