本文整理汇总了Java中java.util.Hashtable.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java Hashtable.keySet方法的具体用法?Java Hashtable.keySet怎么用?Java Hashtable.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Hashtable
的用法示例。
在下文中一共展示了Hashtable.keySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addBindings
import java.util.Hashtable; //导入方法依赖的package包/类
/**
* method merging env into nenv
*
* @throws UnifyException
*/
public static void addBindings(Environment env, Environment nenv)
throws UnifyException {
Hashtable<String, Value> eTable = env.getTable();
Set<String> keys = eTable.keySet();
Iterator<String> it = keys.iterator();
while (it.hasNext()) {
// we look if the variable is bound
String eVar = it.next();
Value val = new Value(Value.VAR, eVar);
Value eVal = env.deref(val);
if (!(eVal.equals(val))) {
// if it is, we unify the bound values in the new environment
Value.unify(val, eVal, nenv);
}
}
}
示例2: getDefaults
import java.util.Hashtable; //导入方法依赖的package包/类
@Override
public UIDefaults getDefaults() {
getColors();
UIDefaults table = new UIDefaults();
// copy existing default values over
// enables AntiAliasing if AntiAliasing is enabled in the OS
// EXCEPT for key "Menu.opaque" which will glitch out JMenues
UIDefaults lookAndFeelDefaults = UIManager.getLookAndFeelDefaults();
Hashtable copy = new Hashtable<>(lookAndFeelDefaults);
for (Object key : copy.keySet()) {
if (!String.valueOf(key).equals("Menu.opaque")) {
table.put(key, lookAndFeelDefaults.get(key));
}
}
initClassDefaults(table);
initSystemColorDefaults(table);
initComponentDefaults(table);
COLORS.addCustomEntriesToTable(table);
return table;
}
示例3: singleNumber
import java.util.Hashtable; //导入方法依赖的package包/类
public int singleNumber(int[] arr) {
Hashtable<Integer, Integer> set = new Hashtable<>();
int number = 0;
for (int i = 0; i < arr.length; i++) {
if (set.containsKey(arr[i])) {
set.put(arr[i], set.get(arr[i]) + 1);
} else {
set.put(arr[i], 1);
}
}
for (Integer key: set.keySet()) {
if (set.get(key) == 1)
return (int) key;
}
return number;
}
示例4: clone
import java.util.Hashtable; //导入方法依赖的package包/类
public static Hashtable<Integer, List<WindowConfiguration>> clone(Hashtable<Integer, List<WindowConfiguration>> obj) {
Hashtable<Integer, List<WindowConfiguration>> newObj = new Hashtable<>();
List<WindowConfiguration> list, clonedList;
for(Integer key : obj.keySet()){
list = obj.get(key);
clonedList = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
clonedList.add(list.get(i).clone());
}
newObj.put(key, clonedList);
}
return newObj;
}
示例5: canFormPalindrome
import java.util.Hashtable; //导入方法依赖的package包/类
public static boolean canFormPalindrome(String s) {
Hashtable<Character, AtomicInteger> count = new Hashtable<>();
for (Character c : s.toLowerCase().toCharArray()) {
if (!count.containsKey(c))
count.put(c, new AtomicInteger(1));
else
count.get(c).getAndIncrement();
}
boolean hasOdd = false;
for (Character key : count.keySet()) {
if (count.get(key).get() % 2 != 0)
if (hasOdd)
return false;
else
hasOdd = true;
}
return true;
}
开发者ID:gardncl,项目名称:elements-of-programming-interviews-solutions,代码行数:20,代码来源:PalindromicPermutations.java
示例6: main
import java.util.Hashtable; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final String ASPECT_DEVICE = "device";
final String nexusUA = "Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1";
final String iri = "http://www.w3.org/2008/01/ddr-core-vocabulary";
final Evidence uaEvidence = new UserAgentEvidence(nexusUA);
final DDRSimpleAPITester tester = new DDRSimpleAPITester(DDRTestService.ODDR_SERVICE, uaEvidence,
iri, ASPECT_DEVICE, "webBrowser",
13,
"version", "jpeg", ASPECT_DEVICE, ASPECT_DEVICE, "", "", "",
1,
"", "",
false,
"", "",
new String[] {""}
);
final Hashtable<?, ?> report = tester.getReport();
if (report.size() > 0) {
System.out.println(report.size() + " entries found.");
for (Object key : report.keySet()) {
System.out.println("Key: " + key + "; " + "Value: " + report.get(key));
}
}
}
示例7: print
import java.util.Hashtable; //导入方法依赖的package包/类
public static String print(Hashtable<String, LinkedList<Object>> psi) {
String res = "";
Set<String> knodes = psi.keySet();
Iterator<String> i = knodes.iterator();
while (i.hasNext()) {
String k = (String) i.next();
res += "Node address " + k + " - trees: { ";
LinkedList<Object> atrees = psi.get(k);
for (int j = 0; j < atrees.size(); j++) {
res += atrees.get(j) + " ";
}
res += "}\n";
}
return res;
}
示例8: mergeTables
import java.util.Hashtable; //导入方法依赖的package包/类
private static void mergeTables(Hashtable<? super String, Object> props1,
Hashtable<? super String, Object> props2) {
for (Object key : props2.keySet()) {
String prop = (String)key;
Object val1 = props1.get(prop);
if (val1 == null) {
props1.put(prop, props2.get(prop));
} else if (isListProperty(prop)) {
String val2 = (String)props2.get(prop);
props1.put(prop, ((String)val1) + ":" + val2);
}
}
}
示例9: convertRealmConfigs
import java.util.Hashtable; //导入方法依赖的package包/类
/**
* convertRealmConfigs: Maps the Object graph that we get from JNI to the
* object graph that Config expects. Also the items inside the kdc array
* are wrapped inside Hashtables
*/
@SuppressWarnings("unchecked")
private static Hashtable<String, Object>
convertRealmConfigs(Hashtable<String, ?> configs) {
Hashtable<String, Object> realmsTable = new Hashtable<String, Object>();
for (String realm : configs.keySet()) {
// get the kdc
Hashtable<String, Collection<?>> map =
(Hashtable<String, Collection<?>>) configs.get(realm);
Hashtable<String, Vector<String>> realmMap =
new Hashtable<String, Vector<String>>();
// put the kdc into the realmMap
Collection<Hashtable<String, String>> kdc =
(Collection<Hashtable<String, String>>) map.get("kdc");
if (kdc != null) realmMap.put("kdc", unwrapHost(kdc));
// put the admin server into the realmMap
Collection<Hashtable<String, String>> kadmin =
(Collection<Hashtable<String, String>>) map.get("kadmin");
if (kadmin != null) realmMap.put("admin_server", unwrapHost(kadmin));
// add the full entry to the realmTable
realmsTable.put(realm, realmMap);
}
return realmsTable;
}
示例10: clone
import java.util.Hashtable; //导入方法依赖的package包/类
/**
* sets the information needed to reconstruct the baseCtx if
* we are serialized. This must be called _before_ the object is
* serialized!!!
*/
@SuppressWarnings("unchecked") // clone()
private void setBaseCtxInfo() {
Hashtable<String, Object> realEnv = null;
Hashtable<String, Object> secureEnv = null;
if (baseCtx != null) {
realEnv = ((LdapCtx)baseCtx).envprops;
this.baseCtxURL = ((LdapCtx)baseCtx).getURL();
}
if(realEnv != null && realEnv.size() > 0 ) {
// remove any security credentials - otherwise the serialized form
// would store them in the clear
for (String key : realEnv.keySet()){
if (key.indexOf("security") != -1 ) {
//if we need to remove props, we must do it to a clone
//of the environment. cloning is expensive, so we only do
//it if we have to.
if(secureEnv == null) {
secureEnv = (Hashtable<String, Object>)realEnv.clone();
}
secureEnv.remove(key);
}
}
}
// set baseCtxEnv depending on whether we removed props or not
this.baseCtxEnv = (secureEnv == null ? realEnv : secureEnv);
}
示例11: getTableModel4Slot
import java.util.Hashtable; //导入方法依赖的package包/类
/**
* This returns the 'DefaultTableModel' for a single
* class out of the ontology-classes.
*
* @return the table model4 slot
*/
public DefaultTableModel getTableModel4Slot() {
DefaultTableModel tm4s = new DefaultTableModel();
tm4s.addColumn("Name");
tm4s.addColumn("Cardinality");
tm4s.addColumn("Type");
tm4s.addColumn("Other Facets");
if (ontologySubClass == null) {
return tm4s;
}
// --- Nach den entsprechenden Slots im Vokabular filtern ---
Hashtable<String, String> ontoSlotHash = ontologyClass.ontologieVocabulary.getSlots(ontologySubClass);
ReflectClass reflectedClass = new ReflectClass(ontologySubClass, ontoSlotHash);
Vector<String> v = new Vector<String>( ontoSlotHash.keySet() );
Collections.sort(v);
Iterator<String> it = v.iterator();
while (it.hasNext()) {
// --- Get Word of the ontology -------------------------
String key = it.next();
String word = ontoSlotHash.get(key);
// --- Get Slot... --------------------------------------
Slot currSlot = reflectedClass.getSlot(word);
// --- Add table row ------------------------------------
Vector<String> rowData = new Vector<String>();
rowData.add(word );
rowData.add(currSlot.Cardinality);
rowData.add(currSlot.VarType);
rowData.add(currSlot.OtherFacts);
tm4s.addRow(rowData);
}
// ----------------------------------------------------------
// --- Are there slots from the parent Node? ----------------
// ----------------------------------------------------------
if (parentOntologyClassTreeObject!=null) {
DefaultTableModel subTBmodel = parentOntologyClassTreeObject.getTableModel4Slot();
Vector<?> subDataVector = subTBmodel.getDataVector();
for (int i = 0; i < subDataVector.size(); i++) {
Vector<?> rowVector = (Vector<?>) subDataVector.get(i);
tm4s.addRow(rowVector);
}
Sorter.sortTableModel(tm4s, 0);
}
// ----------------------------------------------------------
return tm4s;
}
示例12: WrapAllStringInVector
import java.util.Hashtable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static void WrapAllStringInVector(
Hashtable<String, Object> stanzaTable) {
for (String s: stanzaTable.keySet()) {
Object v = stanzaTable.get(s);
if (v instanceof Hashtable) {
WrapAllStringInVector((Hashtable<String,Object>)v);
} else if (v instanceof String) {
Vector<String> vec = new Vector<>();
vec.add((String)v);
stanzaTable.put(s, vec);
}
}
}
示例13: updateFS
import java.util.Hashtable; //导入方法依赖的package包/类
/**
* This method update some FS according to an environment (ie a list of
* bindings)
*/
public static Fs updateFS(Fs fs, Environment env, boolean finalUpdate)
throws UnifyException {
// System.err.println("updating [" + fs.toString() + "] env: " +
// env.toString());
// System.out.println("Starting UpdateFS");
Fs res = null;
if (fs.isTyped()) {
Value coref = fs.getCoref();
Value vderef = env.deref(coref);
if (!(vderef.equals(fs.getCoref()))) { // it is bound:
res = new Fs(fs.getSize(), fs.getType(),
Value.unify(vderef, coref, env));
} else { // it is not:
res = new Fs(fs.getSize(), fs.getType(), vderef);
// This was added for testing
// env.bind(vderef,coref);
}
// System.out.println("Deref of "+fs.getCoref()+":
// "+env.deref(fs.getCoref()));
} else {
res = new Fs(fs.getSize());
}
Hashtable<String, Value> avm = fs.getAVlist();
Set<String> keys = avm.keySet();
Iterator<String> i = keys.iterator();
while (i.hasNext()) {
String k = (String) i.next();
Value fval = avm.get(k);
// System.err.println("Processing ... " +
// k+":"+fval.toString());
switch (fval.getType()) {
case Value.VAL: // for semantic labels
fval.update(env, finalUpdate);
res.setFeat(k, fval);
break;
case Value.VAR:
// if the feature value is a variable,
// we look if it is bound to something in the environment
Value v = env.deref(fval);
if (!(v.equals(fval))) { // it is bound:
res.setFeat(k, Value.unify(fval, v, env));
} else { // it is not:
// System.err.println("Variable not bound ... " + k +
// ":"
// + fval.toString());
res.setFeat(k, fval);
// This was added for testing
// env.bind(k,fval);
}
break;
case Value.AVM: // the value is an avm, we go on updating
res.setFeat(k, new Value(
updateFS(fval.getAvmVal(), env, finalUpdate)));
break;
case Value.ADISJ:
fval.update(env, finalUpdate);
res.setFeat(k, fval);
break;
default:
res.setFeat(k, fval);
}
}
// System.out.println("Finished UpdateFS");
return res;
}
示例14: getNarg
import java.util.Hashtable; //导入方法依赖的package包/类
/**
* Process a narg XML tag to extract a TagNode label
*
* @param e
* the DOM Element corresponding to the feature structure
*
*/
public static Fs getNarg(Element e, int from, NameFactory nf) {
Fs res = null;
try {
NodeList l = e.getChildNodes();
// we declare the hash that will be used for features
// that have to be added to both top and bot
Hashtable<String, Value> toAdd = new Hashtable<String, Value>();
for (int i = 0; i < l.getLength(); i++) {
Node n = l.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element el = (Element) n;
if (el.getTagName().equals("fs")) {
res = getFeats(el, NOFS, toAdd, nf);
}
}
}
if (from == FROM_NODE && toAdd.size() > 0) {
// we post-process the features to add
Value top = res.getFeat("top");
if (top == null) {
top = new Value(new Fs(5));
res.setFeat("top", top);
}
Value bot = res.getFeat("bot");
if (bot == null) {
bot = new Value(new Fs(5));
res.setFeat("bot", bot);
}
Set<String> keys = toAdd.keySet();
Iterator<String> it = keys.iterator();
while (it.hasNext()) {
String f = it.next();
if (!(top.getAvmVal().hasFeat(f))) {
top.getAvmVal().setFeat(f, toAdd.get(f));
}
if (!(bot.getAvmVal().hasFeat(f))) {
bot.getAvmVal().setFeat(f, toAdd.get(f));
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return res;
}
示例15: getClassDescription
import java.util.Hashtable; //导入方法依赖的package包/类
/**
* This returns the a ArrayList of Slots for a single
* class out of the ontology-classes.
*
* @return the class description
*/
public OntologySingleClassDescription getClassDescription() {
OntologySingleClassDescription ocd = null;
OntologySingleClassSlotDescription osd = null;
if ( ontologySubClass == null ) {
return null;
}
// --- Beschreibungsobjekt initialisieren -------------------
ocd = new OntologySingleClassDescription();
ocd.setClazz(ontologySubClass);
ocd.setClassReference(this.getClassReference()); // Package und Class werden hier automatisch gesetzt
// --- Nach den entsprechenden Slots im Vokabular filtern ---
Hashtable<String, String> ontoSlotHash = ontologyClass.ontologieVocabulary.getSlots(ontologySubClass);
ReflectClass reflectedClass = new ReflectClass(ontologySubClass, ontoSlotHash);
Vector<String> v = new Vector<String>(ontoSlotHash.keySet());
Collections.sort(v);
Iterator<String> it = v.iterator();
while (it.hasNext()) {
// --- Wort/Slot der Ontologie ermitteln ---------------
String key = it.next();
String word = ontoSlotHash.get(key);
// --- Slot untersuchen ... -----------------------------
Slot currSlot = reflectedClass.getSlot(word);
// --- Objekt v. Typ 'OntologySlotDescription' erzeugen -
osd = new OntologySingleClassSlotDescription();
osd.setSlotName(word);
osd.setSlotCardinality(currSlot.Cardinality);
osd.setSlotVarType(currSlot.VarType);
osd.setSlotOtherFacts(currSlot.OtherFacts);
osd.setSlotMethodList(currSlot.MethodList);
ocd.getArrayList4SlotDescriptions().add(osd);
}
// ----------------------------------------------------------
// --- Are there slots from the parent Node? ----------------
// ----------------------------------------------------------
if (parentOntologyClassTreeObject!=null) {
OntologySingleClassDescription subOCD = parentOntologyClassTreeObject.getClassDescription();
ocd.getArrayList4SlotDescriptions().addAll(subOCD.getArrayList4SlotDescriptions());
Sorter.sortSlotDescriptionArray(ocd.getArrayList4SlotDescriptions());
}
// ----------------------------------------------------------
return ocd;
}