public V put( int key, V value ) { synchronized( mutex ) { return m.put( key, value ); } } public V remove( int key ) {
/** * Used by FieldMetadata to update the id lookup table * * @param field The field to update the id for * @param id The new id of the field */ @SuppressWarnings("unchecked") void setFieldId(FieldMetadata<T, ?> field, byte id) { if (fields.containsValue(field)) { fieldsById.put(id, (FIELD) field); } }
/** Adds a task to this Job, assigning it a task ID number. */ public void addTask (AnalystClusterRequest task) { tasksById.put(task.taskId, task); tasksAwaitingDelivery.add(task); }
public FrequencyRandomOffsets(RaptorWorkerData data) { this.data = data; if (!data.hasFrequencies) return; data.timetablesForPattern.stream().filter(tt -> tt.hasFrequencyTrips()) .forEach(tt -> { offsets.put(tt.dataIndex, new int[tt.getFrequencyTripCount()]); }); }
/** * Returns a key based on the provided key Id. * @param id The id of the key. * @return The key with this id. */ public static Input find(int id) { Input result = lookupById.get(id); if (result == null) { result = new UnknownInput(InputType.KEY, id); lookupById.put(id, result); lookupByName.put(result.getName(), result); } return result; } }
/** * Inserts a key/value pair into the map. * * @param key an <code>Integer</code> value * @param value an <code>Object</code> value * @return the previous value associated with <tt>key</tt>, * or <tt>null</tt> if none was found. */ public V put( Integer key, V value ) { int k; if ( key == null ) { k = _map.getNoEntryKey(); } else { k = unwrapKey( key ); } return _map.put( k, value ); }
protected static TIntObjectMap<MethodLocation> buildAddressToLocation(MutableMethodImplementation implementation) { List<BuilderInstruction> instructions = implementation.getInstructions(); TIntObjectMap<MethodLocation> addressToLocation = new TIntObjectHashMap<>(instructions.size()); for (BuilderInstruction instruction : instructions) { MethodLocation location = instruction.getLocation(); int address = location.getCodeAddress(); addressToLocation.put(address, location); } return addressToLocation; }
@Before public void setUp() { vm = mock(VirtualMachine.class); mState = mock(MethodState.class); node = mock(ExecutionNode.class); location = mock(MethodLocation.class); when(location.getCodeAddress()).thenReturn(ADDRESS); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new IfOpFactory(); }
@Before public void setUp() { vm = mock(VirtualMachine.class); mState = mock(MethodState.class); node = mock(ExecutionNode.class); location = mock(MethodLocation.class); when(location.getCodeAddress()).thenReturn(ADDRESS); ExceptionFactory exceptionFactory = mock(ExceptionFactory.class); when(vm.getExceptionFactory()).thenReturn(exceptionFactory); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new BinaryMathOpFactory(); }
public int get(String forUseBy) { if (pool.isEmpty()) { IntBuffer buffer = BufferUtils.createIntBuffer(BUFFER_FETCH_SIZE); GL15.glGenBuffers(buffer); for (int i = 0; i < BUFFER_FETCH_SIZE; ++i) { pool.add(buffer.get(i)); } totalPoolSize += BUFFER_FETCH_SIZE; } int result = pool.removeAt(pool.size() - 1); if (traceBufferUsage) { usageTracker.put(result, forUseBy); } return result; }
@BeforeBenchClass @BeforeClass public static void beforeClass() { for (int i = 0; i < data.length; i++) { data[i] = new Integer(i); mySparse.put(i, data[i]); myTrove.put(i, data[i]); } }
@Bench public void timeInsertAndLookupTrove() { TIntObjectMap<Object> trove = new TIntObjectHashMap<Object>(); Object value = null; for (int i = 0; i < data.length; i++) { trove.put(i, data[i]); value = trove.get(i); } value.toString(); }
@Before public void setUp() { vm = mock(VirtualMachine.class); classManager = mock(ClassManager.class); when(vm.getClassManager()).thenReturn(classManager); location = mock(MethodLocation.class); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(SwitchPayload.class)); when(location.getInstruction()).thenReturn(instruction); when(location.getCodeAddress()).thenReturn(ADDRESS); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new SwitchPayloadOpFactory(); }
@Before public void setUp() { vm = mock(VirtualMachine.class); mState = mock(MethodState.class); node = mock(ExecutionNode.class); item = mock(HeapItem.class); when(mState.readRegister(REGISTER_B)).thenReturn(item); location = mock(MethodLocation.class); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction12x.class)); when(location.getInstruction()).thenReturn(instruction); when(location.getCodeAddress()).thenReturn(ADDRESS); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); when(((Instruction12x) instruction).getRegisterA()).thenReturn(REGISTER_A); when(((Instruction12x) instruction).getRegisterB()).thenReturn(REGISTER_B); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new UnaryMathOpFactory(); }
@Before public void setUp() { vm = mock(VirtualMachine.class); node = mock(ExecutionNode.class); mState = mock(MethodState.class); location = mock(MethodLocation.class); instruction = mock(BuilderInstruction.class, withSettings().extraInterfaces(Instruction3rc.class, VariableRegisterInstruction.class, ReferenceInstruction.class, RegisterRangeInstruction.class)); when(location.getInstruction()).thenReturn(instruction); when(location.getCodeAddress()).thenReturn(ADDRESS); when(instruction.getLocation()).thenReturn(location); when(instruction.getCodeUnits()).thenReturn(0); Reference ref = new ImmutableTypeReference("[I"); when(((ReferenceInstruction) instruction).getReference()).thenReturn(ref); addressToLocation = new TIntObjectHashMap<MethodLocation>(); addressToLocation.put(ADDRESS, location); opFactory = new FilledNewArrayOpFactory(); }
@Test public void shiftIntegerMapKeysRemovesWhenShiftingDown() { TIntObjectMap<String> intToObject = new TIntObjectHashMap<String>(); intToObject.put(1, "one"); intToObject.put(2, "two"); intToObject.put(3, "three"); Utils.shiftIntegerMapKeys(1, -1, intToObject); assertEquals(2, intToObject.size()); assertEquals("two", intToObject.get(1)); assertEquals("three", intToObject.get(2)); }
@Test public void shiftIntegerMapKeysShiftsUpAsExpected() { TIntObjectMap<String> intToObject = new TIntObjectHashMap<String>(); intToObject.put(1, "one"); intToObject.put(2, "two"); intToObject.put(3, "three"); Utils.shiftIntegerMapKeys(1, 2, intToObject); assertEquals(3, intToObject.size()); assertEquals("one", intToObject.get(1)); assertEquals("two", intToObject.get(4)); assertEquals("three", intToObject.get(5)); }
@Override public void setTexture(String desc, Texture texture) { if (isDisposed()) { return; } int texId; if (bindMap.containsKey(desc)) { texId = bindMap.get(desc); } else { // TODO: do this initially, and try and have similar textures in similar slots for all materials. ShaderParameterMetadata metadata = shader.getParameter(desc); if (metadata == null || !metadata.getType().isTexture()) { return; } texId = textureIndex++; // Make sure to bind the texture for all permutations setInt(desc, texId); bindMap.put(desc, texId); } textureMap.put(texId, texture); }
public static <T> void shiftIntegerMapKeys(int startKey, int shift, TIntObjectMap<T> intToObject) { if (shift == 0) { return; } TIntList keysToShift = new TIntArrayList(intToObject.keys()); // Exclude anything before and including startKey for (int currentKey : keysToShift.toArray()) { if (currentKey <= startKey) { keysToShift.remove(currentKey); } } keysToShift.sort(); if (shift > 0) { // Shifting keys up, so start at the end to avoid overwriting keys. keysToShift.reverse(); } for (int currentKey : keysToShift.toArray()) { T obj = intToObject.get(currentKey); intToObject.remove(currentKey); intToObject.put(currentKey + shift, obj); } } }