本文整理了Java中jadex.commons.collection.LRU
类的一些代码示例,展示了LRU
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LRU
类的具体详情如下:
包路径:jadex.commons.collection.LRU
类名称:LRU
[英]A least recently used map.
[中]最近使用最少的地图。
代码示例来源:origin: net.sourceforge.jadex/jadex-platform-extension-webservice-desktop
/**
* Create a new publish service.
*/
public DefaultRestServicePublishService(IRestMethodGenerator generator)
{
this.generator = generator;
this.proxyclasses = new LRU<Tuple2<Class<?>, Class<?>>, Class<?>>(50);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-editor-bpmn
/**
* Gets a visual element by BPMN id.
*
* @param id The ID.
* @return The element, null if not found.
*/
public VElement getVisualElementById(mxICell startelement, String id)
{
VElement ret = elementidcache.get(id);
if (ret == null)
{
ret = findElementById(startelement, id);
elementidcache.put(id, ret);
}
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Get data from the cache.
* @param key The key.
* @param now The current time (-1 for never expire).
* @return The cached object.
*/
public Object get(Object key, long now)
{
Object ret = null;
CacheEntry ce = (CacheEntry)lru.get(key);
if(ce!=null)
{
if(ce.isExpired(now))
{
// System.out.println("expired: "+ce.getData()+" "+now+" "+ce.getCacheDate()+" "+ce.getTimeToLive());
lru.remove(key);
}
else
{
// System.out.println("not expired: "+ce.getData()+" "+now+" "+ce.getCacheDate()+" "+ce.getTimeToLive());
ret = ce.getData();
}
}
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Decodes and adds sub-objects during decoding.
*
* @param object The instantiated object.
* @param clazz The class of the object.
* @param context The decoding context.
* @return The finished object.
*/
public Object decodeSubObjects(Object object, Class<?> clazz, IDecodingContext context)
{
LRU ret = (LRU) object;
int maxentries = (int) context.readVarInt();
ret.setMaxEntries(maxentries);
ILRUEntryCleaner cleaner = (ILRUEntryCleaner) BinarySerializer.decodeObject(context);
ret.setCleaner(cleaner);
int size = (int) context.readVarInt();
for (int i = 0; i < size; ++i)
{
Object key = BinarySerializer.decodeObject(context);
Object value = BinarySerializer.decodeObject(context);
ret.put(key, value);
}
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Put an entry in the cache.
* @param key The key.
* @param value The value.
* @param now The current time (-1 for never expire).
*/
public void put(Object key, Object value, long now, long ttl)
{
CacheEntry ce = new CacheEntry(value, now, ttl);
lru.put(key, ce);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-platform
else if(!releasedatecache.containsKey(rec.getRoot()))
Date date = releasedatecache.get(rec.getRoot());
crl.resultAvailable(date);
代码示例来源:origin: org.activecomponents.jadex/jadex-json
wr.writeNameValue("max", lru.getMaxEntries());
if(lru.getCleaner()!=null)
traverser.doTraverse(lru.getCleaner(), lru.getCleaner().getClass(), traversed, processors, clone, targetcl, context);
Set keyset = lru.keySet();
Object[] keys = keyset.toArray(new Object[keyset.size()]);
Object val = lru.get(keys[i]);
Class<?> valclazz = val!=null? val.getClass(): null;
Object key = keys[i];
Object val = lru.get(keys[i]);
Class<?> valclazz = val!=null? val.getClass(): null;
traverser.doTraverse(val, valclazz, traversed, processors, clone, targetcl, context);
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Test if an entry can expire.
* @param key The key.
* @return True, if entry can expire.
*/
public boolean canExpire(Object key)
{
boolean ret = true;
CacheEntry ce = (CacheEntry)lru.get(key);
if(ce!=null)
{
ret = ce.getCacheDate()!=-1;
}
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
((LRU) ret).setMaxEntries(((LRU) object).getMaxEntries());
ILRUEntryCleaner cleaner = ((LRU) object).getCleaner();
if (cleaner != null)
((LRU) ret).setCleaner((ILRUEntryCleaner) traverser.doTraverse(cleaner, cleaner.getClass(), traversed, processors, clone, targetcl, context));
代码示例来源:origin: net.sourceforge.jadex/jadex-platform-base
SendManager[] tmp = (SendManager[])managers.values().toArray(new SendManager[managers.size()]);
final SendManager[] sms = (SendManager[])SUtil.arrayToSet(tmp).toArray(new SendManager[0]);
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
Traverser traverser, Map<Object, Object> traversed, boolean clone, IEncodingContext ec)
ec.writeVarInt(((LRU) object).getMaxEntries());
ILRUEntryCleaner cleaner = ((LRU) object).getCleaner();
if(cleaner == null)
ec.writeVarInt(((LRU) object).size());
Set entries = ((LRU) object).entrySet();
for (Iterator<Map.Entry> it = entries.iterator(); it.hasNext(); )
代码示例来源:origin: net.sourceforge.jadex/jadex-platform-base
/**
* Init the transport.
* @param platform The platform.
* @param settings The settings.
*/
public TCPTransport(final IServiceProvider container, int port, final boolean async)
{
this.logger = Logger.getLogger(AbstractComponentAdapter.getLoggerName(container.getId())+".TCPTransport");
this.container = container;
this.async = async;
this.port = port;
// Set up sending side.
this.connections = SCollection.createLRU(MAX_CONNECTIONS);
((LRU<String, Object>)this.connections).setCleaner(new ILRUEntryCleaner<String, Object>()
{
public void cleanupEldestEntry(Entry<String, Object> eldest)
{
Object con = eldest.getValue();
if(con instanceof TCPOutputConnection)
{
((TCPOutputConnection)con).close();
}
}
});
this.connections = Collections.synchronizedMap(this.connections);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Remove an entry.
* @param key The key.
*/
public boolean remove(Object key)
{
return lru.remove(key)!=null;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Get the size.
* @return The size.
*/
public int size()
{
return lru.size();
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Test if a key is contained.
* @param key The key.
* @return True if contained.
*/
public boolean containsKey(Object key)
{
return lru.containsKey(key);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-json
if(maxentries>0)
ret.setMaxEntries(maxentries);
ret.setCleaner((ILRUEntryCleaner)cl);
ret.put(name, newval);
if(val != Traverser.IGNORE_RESULT)
ret.put(key, val);
代码示例来源:origin: net.sourceforge.jadex/jadex-platform-base
/**
* Add a termination command.
*/
public void addTerminationCommand(String callid, Runnable command)
{
getRemoteReferenceModule().checkThread();
terminationcommands.put(callid, command);
}
代码示例来源:origin: net.sourceforge.jadex/jadex-platform
else if(!releasedatecache.containsKey(rec.getRoot()))
Date date = releasedatecache.get(rec.getRoot());
crl.resultAvailable(date);
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
System.arraycopy(imports, 0, keys, 3, imports.length);
Tuple keytuple = new Tuple(keys);
cached = modelcache.get(keytuple);
代码示例来源:origin: org.activecomponents.jadex/jadex-platform
SendManager[] tmp = (SendManager[])managers.values().toArray(new SendManager[managers.size()]);
final SendManager[] sms = (SendManager[])SUtil.arrayToSet(tmp).toArray(new SendManager[0]);
内容来源于网络,如有侵权,请联系作者删除!