www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,61 @@
|
|||
package org.jcodec.common;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import org.jcodec.platform.Platform;
|
||||
|
||||
public class IntObjectMap<T> {
|
||||
private static final int GROW_BY = 128;
|
||||
|
||||
private Object[] storage = new Object[128];
|
||||
|
||||
private int _size;
|
||||
|
||||
public void put(int key, T val) {
|
||||
if (this.storage.length <= key) {
|
||||
Object[] ns = new Object[key + 128];
|
||||
System.arraycopy(this.storage, 0, ns, 0, this.storage.length);
|
||||
this.storage = ns;
|
||||
}
|
||||
if (this.storage[key] == null)
|
||||
this._size++;
|
||||
this.storage[key] = val;
|
||||
}
|
||||
|
||||
public T get(int key) {
|
||||
return (key >= this.storage.length) ? null : (T)this.storage[key];
|
||||
}
|
||||
|
||||
public int[] keys() {
|
||||
int[] result = new int[this._size];
|
||||
for (int i = 0, r = 0; i < this.storage.length; i++) {
|
||||
if (this.storage[i] != null)
|
||||
result[r++] = i;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (int i = 0; i < this.storage.length; i++)
|
||||
this.storage[i] = null;
|
||||
this._size = 0;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this._size;
|
||||
}
|
||||
|
||||
public void remove(int key) {
|
||||
if (this.storage[key] != null)
|
||||
this._size--;
|
||||
this.storage[key] = null;
|
||||
}
|
||||
|
||||
public T[] values(T[] runtime) {
|
||||
T[] result = (T[])Array.newInstance(Platform.arrayComponentType(runtime), this._size);
|
||||
for (int i = 0, r = 0; i < this.storage.length; i++) {
|
||||
if (this.storage[i] != null)
|
||||
result[r++] = (T)this.storage[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue