当前位置: 首页>>代码示例>>Java>>正文


Java Hashtable.remove方法代码示例

本文整理汇总了Java中java.util.Hashtable.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Hashtable.remove方法的具体用法?Java Hashtable.remove怎么用?Java Hashtable.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Hashtable的用法示例。


在下文中一共展示了Hashtable.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.util.Hashtable; //导入方法依赖的package包/类
public static void main(String[] args) {

    //create Hashtable object
    Hashtable ht = new Hashtable();

    /*
      To get the size of Hashtable use
      int size() method of Hashtable class. It returns the number of key values
      pairs stored in Hashtable object.
    */
    System.out.println("Size of Hashtable : " + ht.size());

    //add key value pairs to Hashtable using put method
    ht.put("1", "One");
    ht.put("2", "Two");
    ht.put("3", "Three");
    System.out.println("Size of Hashtable after addition : " + ht.size());

    //remove one element from Hashtable using remove method
    Object obj = ht.remove("2");
    System.out.println("Size of Hashtable after removal : " + ht.size());
  }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:GetSizeOfHashtableExample.java

示例2: writeIDLEntityIncludes

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Write #includes for boxed IDLEntity references.
 * @param refHash Hashtable loaded with referenced types
 * @param p The output stream.
 */
protected void writeIDLEntityIncludes(
                                      Hashtable refHash,
                                      IndentingWriter p )
    throws IOException {
    Enumeration refEnum = refHash.elements();
    while ( refEnum.hasMoreElements() ) {
        Type t = (Type)refEnum.nextElement();
        if ( t.isCompound() ) {
            CompoundType ct = (CompoundType)t;
            if ( ct.isIDLEntity() ) {                          //select IDLEntities
                writeInclude( ct,0,!isThrown,p );
                refHash.remove( ct.getQualifiedName() );     //avoid another #include
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:IDLGenerator.java

示例3: convertNativeConfig

import java.util.Hashtable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Hashtable<String, Object> convertNativeConfig(
        Hashtable<String, Object> stanzaTable) throws IOException {
    // convert SCDynamicStore realm structure to Java realm structure
    Hashtable<String, ?> realms =
            (Hashtable<String, ?>) stanzaTable.get("realms");
    if (realms == null || realms.isEmpty()) {
        throw new IOException(
                "SCDynamicStore contains an empty Kerberos setting");
    }
    stanzaTable.remove("realms");
    Hashtable<String, Object> realmsTable = convertRealmConfigs(realms);
    stanzaTable.put("realms", realmsTable);
    WrapAllStringInVector(stanzaTable);
    if (DEBUG) System.out.println("stanzaTable : " + stanzaTable);
    return stanzaTable;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:SCDynamicStoreConfig.java

示例4: RemoveObjectFromHashTable

import java.util.Hashtable; //导入方法依赖的package包/类
private void RemoveObjectFromHashTable(Hashtable tab, Object obj)
{
	Enumeration e = tab.keys();
	try
	{
		Object k = e.nextElement() ;
		while (k != null)
		{
			Object o = tab.get(k) ;
			if (o == obj)
			{
				tab.remove(k) ;
			}
			k = e.nextElement() ;
		}
	}
	catch (NoSuchElementException ex)
	{
	}
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:21,代码来源:CObjectCatalog.java

示例5: 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:LdapAttribute.java

示例6: detachWorkspace

import java.util.Hashtable; //导入方法依赖的package包/类
/** Frees all listeners etc from given workspace. */
void detachWorkspace(
    Workspace workspace, Hashtable workspace2Menu, Hashtable menu2Workspace, Hashtable workspace2Listener,
    JMenu menu
) {
    JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) workspace2Menu.get(workspace);
    workspace2Menu.remove(workspace);
    menu2Workspace.remove(workspace2Listener.get(workspace));
    workspace2Listener.remove(workspace);
    menu.remove(menuItem);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:WorkspaceSwitchAction.java

示例7: AmendHashTable

import java.util.Hashtable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void AmendHashTable(int p_HT_nRandomNumber, @SuppressWarnings("rawtypes") Hashtable p_HT_htHash) {
	int nKey;
	boolean blnKeyIsThere;
	Object objGetValue;

	// renaming the Random number passed to the method
	nKey = p_HT_nRandomNumber;

	// Making reading and writing to the hashtable thread safe (this is
	// not an option since I'm using the hashtable as a check
	synchronized (NioApp.class) {
		// checking the Hashtable to see if the random number is there
		blnKeyIsThere = p_HT_htHash.containsKey(" " + nKey);

		// If the random number is there then get the value associated with this
		// key, increase it by one, remove the key (and hence the value)
		// from the hashtable (this ensures that each random number only has one
		// entry in the hashtable) and then put the random number back into
		// the hashtable (as a key) with the new value. If the random number
		// is not there then add it to the hashtable as a key with value one.
		if (blnKeyIsThere) {
			objGetValue = p_HT_htHash.get(" " + nKey);
			String strGetValue = objGetValue.toString();
			int nGetValue = Integer.parseInt(strGetValue);
			int nNewValue = nGetValue + 1;
			p_HT_htHash.remove(" " + nKey);
			p_HT_htHash.put(" " + nKey, new Integer(nNewValue));
			p_HT_htHash.get(" " + nKey);
		} else {
			p_HT_htHash.put(" " + nKey, new Integer(1));
			objGetValue = p_HT_htHash.get(" " + nKey);
		}
		// end synchronized
	}
	// end method AmendHashTable
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-systemtest,代码行数:38,代码来源:NioApp.java

示例8: removeAll

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Removes all the components from this container.
 *
 * @since 1.5
 */
public void removeAll() {
    Component[] children = getComponents();
    Hashtable<Component, Integer> cToL = getComponentToLayer();
    for (int counter = children.length - 1; counter >= 0; counter--) {
        Component c = children[counter];
        if (c != null && !(c instanceof JComponent)) {
            cToL.remove(c);
        }
    }
    super.removeAll();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:JLayeredPane.java

示例9: convertNativeConfig

import java.util.Hashtable; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Hashtable<String, Object> convertNativeConfig(
        Hashtable<String, Object> stanzaTable) {
    // convert SCDynamicStore realm structure to Java realm structure
    Hashtable<String, ?> realms =
            (Hashtable<String, ?>) stanzaTable.get("realms");
    if (realms != null) {
        stanzaTable.remove("realms");
        Hashtable<String, Object> realmsTable = convertRealmConfigs(realms);
        stanzaTable.put("realms", realmsTable);
    }
    WrapAllStringInVector(stanzaTable);
    if (DEBUG) System.out.println("stanzaTable : " + stanzaTable);
    return stanzaTable;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:SCDynamicStoreConfig.java

示例10: startNumberOfRemoteContainer

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * This method will start a number of remote container.
 *
 * @param numberOfContainer the number of container
 * @param remoteContainerConfig the remote container configuration
 * @param filterMainContainer true, if the Main-Container should be filter out of the result
 * 
 * @return the newly started locations
 */
protected Hashtable<String, Location> startNumberOfRemoteContainer(int numberOfContainer, boolean filterMainContainer, RemoteContainerConfig remoteContainerConfig) {
	
	Hashtable<String, Location> newContainerLocations = null;
	
	// --- Is the simulation service running ? -----------------------
	if (isLoadServiceIsRunning()==false) {
		System.out.println("Can not start remote container - LoadService is not running!");
		return null;
	}
	
	// --- Start the required number of container -------------------- 
	int startMistakes = 0;
	int startMistakesMax = 2;
	Vector<String> containerList = new Vector<String>();
	while (containerList.size()< numberOfContainer) {
	
		String newContainer = this.startRemoteContainer(remoteContainerConfig);
		if (newContainer!=null) {
			containerList.add(newContainer);	
		} else {
			startMistakes++;
		}
		if (startMistakes>=startMistakesMax) {
			break;
		}
	}
	
	// --- Get the locations of the started container ----------------
	LoadServiceHelper loadHelper;
	try {
		loadHelper = (LoadServiceHelper) myAgent.getHelper(LoadService.NAME);
		newContainerLocations = loadHelper.getContainerLocations();
		
	} catch (ServiceException e) {
		e.printStackTrace();
		return null;
	}

	// --- If wanted, filter the Main-Container out ------------------
	if (filterMainContainer == true) {
		newContainerLocations.remove(jade.core.AgentContainer.MAIN_CONTAINER_NAME);
		if (newContainerLocations.size()==0) {
			newContainerLocations = null;
		}
	}
	return newContainerLocations;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:57,代码来源:BaseLoadBalancing.java

示例11: getDump

import java.util.Hashtable; //导入方法依赖的package包/类
@Override
public Hashtable<String, Object> getDump() {
    Hashtable<String, Object> result = super.getDump();
    result.remove(AbstractButtonOperator.IS_SELECTED_DPROP);
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:JMenuItemOperator.java

示例12: updateStudentInfo

import java.util.Hashtable; //导入方法依赖的package包/类
protected Student updateStudentInfo(Element element, String externalId, Hashtable<String, Student> students, Session session, Set<Long> updatedStudents) {
   	String fName = element.attributeValue("firstName", "Name");
   	String mName = element.attributeValue("middleName");
   	String lName = element.attributeValue("lastName", "Unknown");
   	String email = element.attributeValue("email");

   	Student student = students.remove(externalId);
   	if (student == null) {
   		student = new Student();
           student.setSession(session);
           student.setExternalUniqueId(externalId);
           student.setFreeTimeCategory(0);
           student.setSchedulePreference(0);
           student.setClassEnrollments(new HashSet<StudentClassEnrollment>());
           student.setCourseDemands(new HashSet<CourseDemand>());
           student.setFirstName(fName);
           student.setMiddleName(mName);
           student.setLastName(lName);
           student.setEmail(email);
           student.setAreaClasfMajors(new HashSet<StudentAreaClassificationMajor>());
           student.setAreaClasfMinors(new HashSet<StudentAreaClassificationMinor>());
           student.setGroups(new HashSet<StudentGroup>());
           student.setAccomodations(new HashSet<StudentAccomodation>());
   	} else {
       	if (!eq(fName, student.getFirstName())) {
       		student.setFirstName(fName);
       		updatedStudents.add(student.getUniqueId());
       	}
       	if (!eq(mName, student.getMiddleName())) {
       		student.setMiddleName(mName);
       		updatedStudents.add(student.getUniqueId());
       	}
       	if (!eq(lName, student.getLastName())) {
       		student.setLastName(lName);
       		updatedStudents.add(student.getUniqueId());
       	}
       	if (!eq(email, student.getEmail())) {
       		student.setEmail(email);
       		updatedStudents.add(student.getUniqueId());
       	}
   	}
   	
   	return student;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:45,代码来源:StudentImport.java

示例13: ReachableObjects

import java.util.Hashtable; //导入方法依赖的package包/类
public ReachableObjects(JavaHeapObject root,
                        final ReachableExcludes excludes) {
    this.root = root;

    final Hashtable<JavaHeapObject, JavaHeapObject> bag = new Hashtable<JavaHeapObject, JavaHeapObject>();
    final Hashtable<String, String> fieldsExcluded = new Hashtable<String, String>();  //Bag<String>
    final Hashtable<String, String> fieldsUsed = new Hashtable<String, String>();   // Bag<String>
    JavaHeapObjectVisitor visitor = new AbstractJavaHeapObjectVisitor() {
        public void visit(JavaHeapObject t) {
            // Size is zero for things like integer fields
            if (t != null && t.getSize() > 0 && bag.get(t) == null) {
                bag.put(t, t);
                t.visitReferencedObjects(this);
            }
        }

        public boolean mightExclude() {
            return excludes != null;
        }

        public boolean exclude(JavaClass clazz, JavaField f) {
            if (excludes == null) {
                return false;
            }
            String nm = clazz.getName() + "." + f.getName();
            if (excludes.isExcluded(nm)) {
                fieldsExcluded.put(nm, nm);
                return true;
            } else {
                fieldsUsed.put(nm, nm);
                return false;
            }
        }
    };
    // Put the closure of root and all objects reachable from root into
    // bag (depth first), but don't include root:
    visitor.visit(root);
    bag.remove(root);

    // Now grab the elements into a vector, and sort it in decreasing size
    JavaThing[] things = new JavaThing[bag.size()];
    int i = 0;
    for (Enumeration e = bag.elements(); e.hasMoreElements(); ) {
        things[i++] = (JavaThing) e.nextElement();
    }
    ArraySorter.sort(things, new Comparer() {
        public int compare(Object lhs, Object rhs) {
            JavaThing left = (JavaThing) lhs;
            JavaThing right = (JavaThing) rhs;
            int diff = right.getSize() - left.getSize();
            if (diff != 0) {
                return diff;
            }
            return left.compareTo(right);
        }
    });
    this.reachables = things;

    this.totalSize = root.getSize();
    for (i = 0; i < things.length; i++) {
        this.totalSize += things[i].getSize();
    }

    excludedFields = getElements(fieldsExcluded);
    usedFields = getElements(fieldsUsed);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:67,代码来源:ReachableObjects.java

示例14: registerWithKeyboardManager

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Registers any bound <code>WHEN_IN_FOCUSED_WINDOW</code> actions with
 * the <code>KeyboardManager</code>. If <code>onlyIfNew</code>
 * is true only actions that haven't been registered are pushed
 * to the <code>KeyboardManager</code>;
 * otherwise all actions are pushed to the <code>KeyboardManager</code>.
 *
 * @param onlyIfNew  if true, only actions that haven't been registered
 *          are pushed to the <code>KeyboardManager</code>
 */
private void registerWithKeyboardManager(boolean onlyIfNew) {
    InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
    KeyStroke[] strokes;
    Hashtable<KeyStroke, KeyStroke> registered =
            (Hashtable<KeyStroke, KeyStroke>)getClientProperty
                            (WHEN_IN_FOCUSED_WINDOW_BINDINGS);

    if (inputMap != null) {
        // Push any new KeyStrokes to the KeyboardManager.
        strokes = inputMap.allKeys();
        if (strokes != null) {
            for (int counter = strokes.length - 1; counter >= 0;
                 counter--) {
                if (!onlyIfNew || registered == null ||
                    registered.get(strokes[counter]) == null) {
                    registerWithKeyboardManager(strokes[counter]);
                }
                if (registered != null) {
                    registered.remove(strokes[counter]);
                }
            }
        }
    }
    else {
        strokes = null;
    }
    // Remove any old ones.
    if (registered != null && registered.size() > 0) {
        Enumeration<KeyStroke> keys = registered.keys();

        while (keys.hasMoreElements()) {
            KeyStroke ks = keys.nextElement();
            unregisterWithKeyboardManager(ks);
        }
        registered.clear();
    }
    // Updated the registered Hashtable.
    if (strokes != null && strokes.length > 0) {
        if (registered == null) {
            registered = new Hashtable<KeyStroke, KeyStroke>(strokes.length);
            putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, registered);
        }
        for (int counter = strokes.length - 1; counter >= 0; counter--) {
            registered.put(strokes[counter], strokes[counter]);
        }
    }
    else {
        putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, null);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:JComponent.java

示例15: ReachableObjects

import java.util.Hashtable; //导入方法依赖的package包/类
public ReachableObjects(JavaHeapObject root,
                        final ReachableExcludes excludes) {
    this.root = root;

    final Hashtable<JavaHeapObject, JavaHeapObject> bag = new Hashtable<JavaHeapObject, JavaHeapObject>();
    final Hashtable<String, String> fieldsExcluded = new Hashtable<String, String>();  //Bag<String>
    final Hashtable<String, String> fieldsUsed = new Hashtable<String, String>();   // Bag<String>
    JavaHeapObjectVisitor visitor = new AbstractJavaHeapObjectVisitor() {
        public void visit(JavaHeapObject t) {
            // Size is zero for things like integer fields
            if (t != null && t.getSize() > 0 && bag.get(t) == null) {
                bag.put(t, t);
                t.visitReferencedObjects(this);
            }
        }

        public boolean mightExclude() {
            return excludes != null;
        }

        public boolean exclude(JavaClass clazz, JavaField f) {
            if (excludes == null) {
                return false;
            }
            String nm = clazz.getName() + "." + f.getName();
            if (excludes.isExcluded(nm)) {
                fieldsExcluded.put(nm, nm);
                return true;
            } else {
                fieldsUsed.put(nm, nm);
                return false;
            }
        }
    };
    // Put the closure of root and all objects reachable from root into
    // bag (depth first), but don't include root:
    visitor.visit(root);
    bag.remove(root);

    // Now grab the elements into a vector, and sort it in decreasing size
    JavaThing[] things = new JavaThing[bag.size()];
    int i = 0;
    for (Enumeration<JavaHeapObject> e = bag.elements(); e.hasMoreElements(); ) {
        things[i++] = (JavaThing) e.nextElement();
    }
    ArraySorter.sort(things, new Comparer() {
        public int compare(Object lhs, Object rhs) {
            JavaThing left = (JavaThing) lhs;
            JavaThing right = (JavaThing) rhs;
            long diff = right.getSize() - left.getSize();
            if (diff != 0) {
                return Long.signum(diff);
            }
            return left.compareTo(right);
        }
    });
    this.reachables = things;

    this.totalSize = root.getSize();
    for (i = 0; i < things.length; i++) {
        this.totalSize += things[i].getSize();
    }

    excludedFields = getElements(fieldsExcluded);
    usedFields = getElements(fieldsUsed);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:67,代码来源:ReachableObjects.java


注:本文中的java.util.Hashtable.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。