@SuppressWarnings("unchecked") private int count(final Object o) { if(!contains(o)) return 0; // otherwise o must be an E: return map.get((E)o); }
private PSequence<Entry<K,V>> getEntries(final int hash) { PSequence<Entry<K,V>> entries = intMap.get(hash); if(entries==null) return ConsPStack.empty(); return entries; }
private PSequence<Entry<K,V>> getEntries(final int hash) { PSequence<Entry<K,V>> entries = intMap.get(hash); if(entries==null) return ConsPStack.empty(); return entries; }
@SuppressWarnings("unchecked") private int count(final Object o) { if(!contains(o)) return 0; // otherwise o must be an E: return map.get((E)o); }
/** * @param key * @return * @see java.util.Map#get(java.lang.Object) */ @Override public V get(final Object key) { return map.get(key); }
@Override @SuppressWarnings("unchecked") public <T> Optional<T> get(Key<? extends T> key) { return Optional.ofNullable((T) values.get(key)); }
assertEquals(map.get(k), pmap.get(k)); assertEquals(map.get(k), pmap.get(k)); assertTrue(map.entrySet().contains(e)); assertTrue(pmap.entrySet().contains(e)); assertEquals(map.get(k), pmap.get(k)); map.remove(k); pmap = pmap.minus(k); assertEquals(null, pmap.get(s)); assertFalse( pmap.entrySet().contains(s) ); pmap = pmap.minus(s);
assertEquals(map.get(k), pmap.get(k)); assertEquals(map.get(k), pmap.get(k)); assertTrue(map.entrySet().contains(e)); assertTrue(pmap.entrySet().contains(e)); assertEquals(map.get(k), pmap.get(k)); map.remove(k); pmap = pmap.minus(k); assertEquals(null, pmap.get(s)); assertFalse( pmap.entrySet().contains(s) ); pmap = pmap.minus(s);
public Scope peek() { if (currentId == null) { throw new IllegalArgumentException("No current scope"); } Scope s = scopes.get(currentId); if (s == null) { throw new IllegalStateException("Invalid current scope ID: " + currentId); } return s; }
@SuppressWarnings("unchecked") private int count(final Object o) { if(!contains(o)) return 0; // otherwise o must be an E: return map.get((E)o); }
public void testMap() { PMap<Object,String> m = HashTreePMap.<Object,String>empty(); assertEquals(m.size(),0); m = m.plus(1,"One"); assertEquals(m.get(1),"One"); // last three have same hashCode: Object[] keys = {1,2,0,3,ConsPStack.empty()}; String[] values = {"one","two","","three","emptyList"}; for(int i=0;i<keys.length;i++) { m = m.plus(keys[i],values[i]); m = m.minus(keys[i]); m = m.plus(keys[i],values[i]); assertEquals(m.size(),i+1); assertEquals(m.get(keys[i]),values[i]); } for(int i=keys.length-1;i>=0;i--) { m = m.minus(keys[i]); assertEquals(m.size(),i); } }
public Scopes pop() { if (currentId == null) { throw new IllegalStateException("Invalid state: no scope to pop"); } Scope s = scopes.get(currentId); if (s == null) { throw new IllegalStateException("Invalid current scope ID: " + currentId); } return new Scopes(s.getParentId(), this.scopes); }
public Fork increment(String flowId, int diff) { int c; Integer cobj = flowCounts.get(flowId); if (cobj == null) { c = 0; } else { c = cobj.intValue(); } return new Fork(flows.plus(flowId), flowCounts.plus(flowId, c + diff)); } }
private void mergeProxies(Class key,PSet<ProxyWrapper> proxies){ val current = proxyCache.get(key); proxyCache.minus(key); val newProxies = current==null ? proxies : proxies.plusAll(current); proxyCache = proxyCache.plus(key, newProxies); }
private PSet<ProxyWrapper> removeProxies(Class key){ val proxies = proxyCache.get(key); val proxiesToUse = proxies==null ? HashTreePSet.singleton(new ProxyWrapper((Proxy)Proxy.newProxyInstance(InvokeDynamicComprehender.class.getClassLoader(), new Class[]{key},new FunctionExecutionInvocationHandler()))) : proxies; if(proxies!=null) proxyCache = proxyCache.minus(key); return proxiesToUse; } private void mergeProxies(Class key,PSet<ProxyWrapper> proxies){
private PSet<ProxyWrapper> removeProxies(Class key){ val proxies = proxyCache.get(key); val proxiesToUse = proxies==null ? HashTreePSet.singleton(new ProxyWrapper((Proxy)Proxy.newProxyInstance(InvokeDynamicComprehender.class.getClassLoader(), new Class[]{key},new FunctionExecutionInvocationHandler()))) : proxies; if(proxies!=null) proxyCache = proxyCache.minus(key); return proxiesToUse; } private void mergeProxies(Class key,PSet<ProxyWrapper> proxies){
private void mergeProxies(Class key,PSet<ProxyWrapper> proxies){ val current = proxyCache.get(key); proxyCache.minus(key); val newProxies = current==null ? proxies : proxies.plusAll(current); proxyCache = proxyCache.plus(key, newProxies); }
private synchronized void mergeProxies(Class key,PSet<ProxyWrapper> proxies){ val current = proxyCache.get(key); proxyCache.minus(key); val newProxies = current==null ? proxies : proxies.plusAll(current); proxyCache = proxyCache.plus(key, newProxies); }
public Activation getActivation(Scopes scopes, UUID scope, String elementId) { while (scope != null) { ActivationKey k = new ActivationKey(scope, elementId); Activation v = values.get(k); if (v != null) { return v; } scope = scopes.values().get(scope).getParentId(); } return Activation.notEmpty(null, scope + ":" + elementId); }
public Events removeEvent(UUID scopeId, UUID eventId) { PMap<UUID, EventRecord> scope = this.events.get(scopeId); if (scope == null) { throw new IllegalArgumentException("Scope not found: " + scopeId); } scope = scope.minus(eventId); if (scope.isEmpty()) { return new Events(this.events.minus(scopeId)); } else { return new Events(this.events.plus(scopeId, scope)); } }