/** * <code><pre> * type ::= string * ::= int * </code></pre> */ private void writeType(String type) throws IOException { flushIfFull(); int len = type.length(); if (len == 0) { throw new IllegalArgumentException("empty type is not allowed"); } if (_typeRefs == null) _typeRefs = new HashMap(); Integer typeRefV = (Integer) _typeRefs.get(type); if (typeRefV != null) { int typeRef = typeRefV.intValue(); writeInt(typeRef); } else { _typeRefs.put(type, Integer.valueOf(_typeRefs.size())); writeString(type); } }
@Override protected void setUp() throws Exception { super.setUp(); System.setProperty("dexmaker.dexcache", "/data/data/" + BuildConfig.APPLICATION_ID + ".test/cache"); mDataStore = new HashMap<>(); mDataStore.put(OLD_KEY, DATA); assertEquals(1, mDataStore.size()); mTrayPreference = new MockSimplePreferences(1); assertEquals(0, mTrayPreference.getAll().size()); } }
public String[][] getHeaders(Object value, Operation operation) throws ServiceException { Response delegate = (Response) value; HashMap map = new HashMap(); if (delegate.getContentDisposition() != null) { map.put("Content-Disposition", delegate.getContentDisposition()); } HashMap m = delegate.getResponseHeaders(); if (m != null && !m.isEmpty()) { map.putAll(m); } if (map == null || map.isEmpty()) return null; String[][] headers = new String[map.size()][2]; List keys = new ArrayList(map.keySet()); for (int i = 0; i < headers.length; i++) { headers[i][0] = (String) keys.get(i); headers[i][1] = (String) map.get(keys.get(i)); } return headers; }
private HashMap<String, ByteIterator> extractResult(Document item) { if (null == item) { return null; } HashMap<String, ByteIterator> rItems = new HashMap<>(item.getHashMap().size()); for (Entry<String, Object> attr : item.getHashMap().entrySet()) { LOGGER.trace("Result- key: {}, value: {}", attr.getKey(), attr.getValue().toString()); rItems.put(attr.getKey(), new StringByteIterator(attr.getValue().toString())); } return rItems; }
/** * Update session meta data information and get the information in a map. * * @return a map containing the session meta data */ HashMap<String, Object> getInfo() { HashMap<String, Object> m = new HashMap<>(map.size() + 5); m.putAll(map); m.put("lastAccess", new Timestamp(lastAccess).toString()); try { m.put("url", conn == null ? "${text.admin.notConnected}" : conn.getMetaData().getURL()); m.put("user", conn == null ? "-" : conn.getMetaData().getUserName()); m.put("lastQuery", commandHistory.isEmpty() ? "" : commandHistory.get(0)); m.put("executing", executingStatement == null ? "${text.admin.no}" : "${text.admin.yes}"); } catch (SQLException e) { DbException.traceThrowable(e); } return m; }
private HashMap<String, String> mData = new HashMap<String, String>(); private String[] mKeys; public HashMapAdapter(HashMap<String, String> data){ mData = data; mKeys = mData.keySet().toArray(new String[data.size()]); return mData.size(); return mData.get(mKeys[position]);
eForm = s1.isElementFormDefault() || s2.isElementFormDefault(); HashMap m = new HashMap(); for (int i = 0; i < ag1.length; i++) m.put(ag1[i].getName(), ag1[i]); attributeGroups = new AttributeGroup[m.size()]; Object[] obj = m.values().toArray(); attributes = new Attribute[m.size()]; obj = m.values().toArray(); complexTypes = new ComplexType[m.size()]; obj = m.values().toArray(); simpleTypes = new SimpleType[m.size()]; obj = m.values().toArray(); elements = new Element[m.size()]; obj = m.values().toArray(); groups = new Group[m.size()]; obj = m.values().toArray(); imports = new Schema[m.size()]; obj = m.values().toArray();
/** * Get the class id, or null if not found. * * @param clazz the class * @return the class id or null */ static Integer getCommonClassId(Class<?> clazz) { HashMap<Class<?>, Integer> map = COMMON_CLASSES_MAP; if (map.size() == 0) { // lazy initialization // synchronized, because the COMMON_CLASSES_MAP is not synchronized (map) { if (map.size() == 0) { for (int i = 0, size = COMMON_CLASSES.length; i < size; i++) { map.put(COMMON_CLASSES[i], i); } } } } return map.get(clazz); }
private void calcAV() { System.out.println("count: "+left.size()); Iterator<String> it = left.keySet().iterator(); while(it.hasNext()){ String key = it.next(); Double l = Math.log(left.get(key).size()); Double r = Math.log(right.get(key).size()); av.put(key, (int)Math.min(l, r)); } System.out.println("av count: "+av.size()); }
private static int increment(HashMap<String, Integer> map, String trace, int minCount) { Integer oldCount = map.get(trace); if (oldCount == null) { map.put(trace, 1); } else { map.put(trace, oldCount + 1); } while (map.size() > MAX_ELEMENTS) { for (Iterator<Map.Entry<String, Integer>> ei = map.entrySet().iterator(); ei.hasNext();) { Map.Entry<String, Integer> e = ei.next(); if (e.getValue() <= minCount) { ei.remove(); } } if (map.size() > MAX_ELEMENTS) { minCount++; } } return minCount; }
@Override void apply(Env env, int argcnt, ASTApply apply) { final boolean warn_missing = env.popDbl() == 1; final String replace = env.popStr(); String skey = env.key(); Frame fr = env.popAry(); if (fr.numCols() != 1) throw new IllegalArgumentException("revalue works on a single column at a time."); String[] old_dom = fr.anyVec()._domain; if (old_dom == null) throw new IllegalArgumentException("Column is not a factor column. Can only revalue a factor column."); HashMap<String, String> dom_map = hashMap(replace); for (int i = 0; i < old_dom.length; ++i) { if (dom_map.containsKey(old_dom[i])) { old_dom[i] = dom_map.get(old_dom[i]); dom_map.remove(old_dom[i]); } } if (dom_map.size() > 0 && warn_missing) { for (String k : dom_map.keySet()) { env._warnings = Arrays.copyOf(env._warnings, env._warnings.length + 1); env._warnings[env._warnings.length - 1] = "Warning: old value " + k + " not a factor level."; } } }
int nextId = getAbstractListDefinitions().size(); do { nextId++; } while (getAbstractListDefinitions().containsKey( "" + nextId )); abstractNum.setAbstractNumId( BigInteger.valueOf(nextId) ); abstractListDefinitions.put(absNumDef.getID(), absNumDef); num.setAbstractNumId(abstractNumId); nextId = getInstanceListDefinitions().size(); do { nextId++; } while (getInstanceListDefinitions().containsKey( "" + nextId )); num.setNumId( BigInteger.valueOf(nextId) ); instanceListDefinitions.put(listDef.getListNumberId(), listDef);