本文整理汇总了Java中org.apache.commons.collections.MapIterator类的典型用法代码示例。如果您正苦于以下问题:Java MapIterator类的具体用法?Java MapIterator怎么用?Java MapIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapIterator类属于org.apache.commons.collections包,在下文中一共展示了MapIterator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toString
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
/**
* Gets the map as a String.
*
* @return a string version of the map
*/
public String toString() {
if (size() == 0) {
return "{}";
}
StringBuffer buf = new StringBuffer(32 * size());
buf.append('{');
MapIterator it = mapIterator();
boolean hasNext = it.hasNext();
while (hasNext) {
Object key = it.next();
Object value = it.getValue();
buf.append(key == this ? "(this Map)" : key)
.append('=')
.append(value == this ? "(this Map)" : value);
hasNext = it.hasNext();
if (hasNext) {
buf.append(',').append(' ');
}
}
buf.append('}');
return buf.toString();
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:31,代码来源:AbstractHashedMap.java
示例2: removeScope
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
/**
* A method which is used to remove variables and functions from the
* symbol table when they are out of scope.
*/
protected void removeScope()
{
MapIterator mp = symtab.mapIterator();
ArrayList<String> variables = new ArrayList<String>();
while(mp.hasNext())
{
MultiKey mult = ((MultiKey)mp.next());
if(mult.getKey(1) == scope)
{
variables.add(mult.getKey(0).toString());
}
}
for(int i = 0; i < variables.size(); i++)
{
symtab.remove(variables.get(i), scope);
}
scope--;
}
开发者ID:gnu-user,项目名称:guidoless-python,代码行数:25,代码来源:MyNode.java
示例3: initialize
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
public final void initialize() {
if (cacheManager != null) {
cacheManager.cancel();
}
cacheManager = new Timer(true);
cacheManager.schedule(new TimerTask() {
public void run() {
long now = System.currentTimeMillis();
try {
MapIterator itr = cacheMap.mapIterator();
while (itr.hasNext()) {
Object key = itr.next();
final CachedObject cobj = (CachedObject) itr.getValue();
if (cobj == null || cobj.hasExpired(now)) {
if (logger.isDebugEnabled()) {
logger.debug("----Inside CRMSessionCache: removing " + key + ": Idle time= " + (now - cobj.timeAccessedLast) + "; Stale time= "
+ (now - cobj.timeCached) + "; Object count in cache= " + cacheMap.size());
}
itr.remove();
Thread.yield();
}
}
} catch (ConcurrentModificationException cme) {
/*
* This is just a timer cleaning up. It will catch up on cleaning next time it runs.
*/
if (logger.isDebugEnabled()) {
logger.debug("----Inside CRMSessionCache:Ignorable ConcurrentModificationException");
}
}
}
}, 0, tiv);
}
开发者ID:inbravo,项目名称:scribe,代码行数:35,代码来源:CRMSessionCache.java
示例4: forgetEntry
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
void forgetEntry(@Nonnull RemoteDirectoryEntry entry) {
synchronized (localCache) {
MapIterator i = localCache.mapIterator();
while (i.hasNext()) {
Object key = i.next();
if (entry == i.getValue()) {
localCache.remove(key);
break;
}
}
}
}
开发者ID:apache,项目名称:incubator-taverna-server,代码行数:13,代码来源:DirectoryDelegate.java
示例5: printReport
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
/**
* Display results to the user.
* @param result
*/
protected void printReport(BidiMap result) {
final String Dash6 = "------";
final String Dash10 = "----------";
final String Dash60 = "------------------------------------------------------------";
Formatter f = new Formatter();
// Print header.
String format = "%-5.5s|%-10.10s|%-60.60s\n";
Object[] hSep = new Object[] { Dash6, Dash10, Dash60 };
f.format(format, hSep);
f.format(format, new Object[] { "Score", "Code", "Term" });
f.format(format, hSep);
// Iterate over the result.
for (MapIterator items = result.inverseBidiMap().mapIterator(); items.hasNext(); ) {
ScoredTerm st = (ScoredTerm) items.next();
String code = (String) items.getValue();
// Evaluate code
if (code != null && code.length() > 10)
code = code.substring(0, 7) + "...";
// Evaluate term (wrap if necessary)
String term = st.term;
if (term != null && term.length() < 60)
f.format(format, new Object[] {st.score, code, term });
else {
String sub = term.substring(0, 60);
f.format(format, new Object[] {st.score, code, sub });
int begin = 60; int end = term.length();
while (begin < end) {
sub = term.substring(begin, Math.min(begin+60, end));
f.format(format, new Object[] {"", "", sub });
begin+=60;
}
}
}
Util.displayMessage(f.out().toString());
}
开发者ID:NCIP,项目名称:nci-term-browser,代码行数:45,代码来源:ScoreTerm.java
示例6: doWriteObject
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
/**
* Replaces the superclass method to store the state of this class.
* <p>
* Serialization is not one of the JDK's nicest topics. Normal serialization will
* initialise the superclass before the subclass. Sometimes however, this isn't
* what you want, as in this case the <code>put()</code> method on read can be
* affected by subclass state.
* <p>
* The solution adopted here is to serialize the state data of this class in
* this protected method. This method must be called by the
* <code>writeObject()</code> of the first serializable subclass.
* <p>
* Subclasses may override if they have a specific field that must be present
* on read before this implementation will work. Generally, the read determines
* what must be serialized here, if anything.
*
* @param out the output stream
*/
protected void doWriteObject(ObjectOutputStream out) throws IOException {
out.writeInt(keyType);
out.writeInt(valueType);
out.writeBoolean(purgeValues);
out.writeFloat(loadFactor);
out.writeInt(data.length);
for (MapIterator it = mapIterator(); it.hasNext();) {
out.writeObject(it.next());
out.writeObject(it.getValue());
}
out.writeObject(null); // null terminate map
// do not call super.doWriteObject() as code there doesn't work for reference map
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:32,代码来源:AbstractReferenceMap.java
示例7: mapIterator
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
/**
* Gets an iterator over the map.
* Changes made to the iterator affect this map.
* <p>
* A MapIterator returns the keys in the map. It also provides convenient
* methods to get the key and value, and set the value.
* It avoids the need to create an entrySet/keySet/values object.
* It also avoids creating the Map.Entry object.
*
* @return the map iterator
*/
public MapIterator mapIterator() {
if (size == 0) {
return EmptyMapIterator.INSTANCE;
}
return new HashMapIterator(this);
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:18,代码来源:AbstractHashedMap.java
示例8: doWriteObject
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
/**
* Writes the map data to the stream. This method must be overridden if a
* subclass must be setup before <code>put()</code> is used.
* <p>
* Serialization is not one of the JDK's nicest topics. Normal serialization will
* initialise the superclass before the subclass. Sometimes however, this isn't
* what you want, as in this case the <code>put()</code> method on read can be
* affected by subclass state.
* <p>
* The solution adopted here is to serialize the state data of this class in
* this protected method. This method must be called by the
* <code>writeObject()</code> of the first serializable subclass.
* <p>
* Subclasses may override if they have a specific field that must be present
* on read before this implementation will work. Generally, the read determines
* what must be serialized here, if anything.
*
* @param out the output stream
*/
protected void doWriteObject(ObjectOutputStream out) throws IOException {
out.writeFloat(loadFactor);
out.writeInt(data.length);
out.writeInt(size);
for (MapIterator it = mapIterator(); it.hasNext();) {
out.writeObject(it.next());
out.writeObject(it.getValue());
}
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:29,代码来源:AbstractHashedMap.java
示例9: mapIterator
import org.apache.commons.collections.MapIterator; //导入依赖的package包/类
/**
* Gets a MapIterator over the reference map.
* The iterator only returns valid key/value pairs.
*
* @return a map iterator
*/
public MapIterator mapIterator() {
return new ReferenceMapIterator(this);
}
开发者ID:PhilippC,项目名称:keepass2android,代码行数:10,代码来源:AbstractReferenceMap.java
注:本文中的org.apache.commons.collections.MapIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论