Search in sources :

Example 66 with Iterator

use of java.util.Iterator in project j2objc by google.

the class IdentityHashMapTest method test_keySet_clear.

/**
	 * @tests java.util.IdentityHashMap#keySet()
	 * @tests java.util.IdentityHashMap#clear()
	 */
public void test_keySet_clear() {
    IdentityHashMap map = new IdentityHashMap();
    for (int i = 0; i < 1000; i++) {
        map.put(new Integer(i), new Integer(i));
    }
    Set set = map.keySet();
    set.clear();
    assertEquals("did not remove all elements in the map", 0, map.size());
    assertTrue("did not remove all elements in the keyset", set.isEmpty());
    Iterator it = set.iterator();
    assertTrue("keySet iterator still has elements", !it.hasNext());
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) TreeSet(java.util.TreeSet) IdentityHashMap(java.util.IdentityHashMap) Iterator(java.util.Iterator)

Example 67 with Iterator

use of java.util.Iterator in project j2objc by google.

the class IdentityHashMapTest method test_keySet_removeAll.

/**
	 * @tests java.util.IdentityHashMap#keySet()
	 * @tests java.util.IdentityHashMap#remove(java.lang.Object)
	 */
public void test_keySet_removeAll() {
    IdentityHashMap map = new IdentityHashMap();
    for (int i = 0; i < 1000; i++) {
        map.put(new Integer(i), new Integer(i));
    }
    Set set = map.keySet();
    set.removeAll(set);
    assertEquals("did not remove all elements in the map", 0, map.size());
    assertTrue("did not remove all elements in the keyset", set.isEmpty());
    Iterator it = set.iterator();
    assertTrue("keySet iterator still has elements", !it.hasNext());
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) TreeSet(java.util.TreeSet) IdentityHashMap(java.util.IdentityHashMap) Iterator(java.util.Iterator)

Example 68 with Iterator

use of java.util.Iterator in project android-maps-utils by googlemaps.

the class GeoJsonParser method parseProperties.

/**
     * Parses the properties of a GeoJSON feature into a hashmap
     *
     * @param properties GeoJSON properties member
     * @return hashmap containing property values
     * @throws JSONException if the properties could not be parsed
     */
private static HashMap<String, String> parseProperties(JSONObject properties) throws JSONException {
    HashMap<String, String> propertiesMap = new HashMap<String, String>();
    Iterator propertyKeys = properties.keys();
    while (propertyKeys.hasNext()) {
        String key = (String) propertyKeys.next();
        propertiesMap.put(key, properties.isNull(key) ? null : properties.getString(key));
    }
    return propertiesMap;
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator)

Example 69 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class GroovyMain method processFiles.

/**
     * Process the input files.
     */
private void processFiles() throws CompilationFailedException, IOException, URISyntaxException {
    GroovyShell groovy = new GroovyShell(conf);
    setupContextClassLoader(groovy);
    Script s = groovy.parse(getScriptSource(isScriptFile, script));
    if (args.isEmpty()) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(System.out);
        try {
            processReader(s, reader, writer);
        } finally {
            reader.close();
            writer.close();
        }
    } else {
        Iterator i = args.iterator();
        while (i.hasNext()) {
            String filename = (String) i.next();
            //TODO: These are the arguments for -p and -i.  Why are we searching using Groovy script extensions?
            // Where is this documented?
            File file = huntForTheScriptFile(filename);
            processFile(s, file);
        }
    }
}
Also used : Script(groovy.lang.Script) Iterator(java.util.Iterator) GroovyShell(groovy.lang.GroovyShell)

Example 70 with Iterator

use of java.util.Iterator in project groovy-core by groovy.

the class GroovyInternalPosixParser method flatten.

/**
     * An implementation of {@link Parser}'s abstract
     * {@link Parser#flatten(Options,String[],boolean) flatten} method.
     * <p>
     * The following are the rules used by this flatten method.
     * <ol>
     *  <li>if <code>stopAtNonOption</code> is <b>true</b> then do not
     *  burst anymore of <code>arguments</code> entries, just add each
     *  successive entry without further processing.  Otherwise, ignore
     *  <code>stopAtNonOption</code>.</li>
     *  <li>if the current <code>arguments</code> entry is "<b>--</b>"
     *  just add the entry to the list of processed tokens</li>
     *  <li>if the current <code>arguments</code> entry is "<b>-</b>"
     *  just add the entry to the list of processed tokens</li>
     *  <li>if the current <code>arguments</code> entry is two characters
     *  in length and the first character is "<b>-</b>" then check if this
     *  is a valid {@link Option} id.  If it is a valid id, then add the
     *  entry to the list of processed tokens and set the current {@link Option}
     *  member.  If it is not a valid id and <code>stopAtNonOption</code>
     *  is true, then the remaining entries are copied to the list of
     *  processed tokens.  Otherwise, the current entry is ignored.</li>
     *  <li>if the current <code>arguments</code> entry is more than two
     *  characters in length and the first character is "<b>-</b>" then
     *  we need to burst the entry to determine its constituents.  For more
     *  information on the bursting algorithm see
     *  {@link GroovyInternalPosixParser#burstToken(String, boolean) burstToken}.</li>
     *  <li>if the current <code>arguments</code> entry is not handled
     *  by any of the previous rules, then the entry is added to the list
     *  of processed tokens.</li>
     * </ol>
     *
     * @param options The command line {@link Options}
     * @param arguments The command line arguments to be parsed
     * @param stopAtNonOption Specifies whether to stop flattening when an non option is found.
     * @return The flattened <code>arguments</code> String array.
     */
protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption) {
    init();
    this.options = options;
    // an iterator for the command line tokens
    Iterator iter = Arrays.asList(arguments).iterator();
    // process each command line token
    while (iter.hasNext()) {
        // get the next command line token
        String token = (String) iter.next();
        // handle long option --foo or --foo=bar
        if (token.startsWith("--")) {
            int pos = token.indexOf('=');
            // --foo
            String opt = pos == -1 ? token : token.substring(0, pos);
            if (!options.hasOption(opt)) {
                processNonOptionToken(token, stopAtNonOption);
            } else {
                tokens.add(opt);
                if (pos != -1) {
                    tokens.add(token.substring(pos + 1));
                } else {
                    currentOption = options.getOption(opt);
                }
            }
        } else // single hyphen
        if ("-".equals(token)) {
            tokens.add(token);
        } else if (token.startsWith("-")) {
            if (token.length() == 2 || options.hasOption(token)) {
                processOptionToken(token, stopAtNonOption);
            } else // requires bursting
            {
                burstToken(token, stopAtNonOption);
            }
        } else {
            processNonOptionToken(token, stopAtNonOption);
        }
        gobble(iter);
    }
    return (String[]) tokens.toArray(new String[tokens.size()]);
}
Also used : Iterator(java.util.Iterator)

Aggregations

Iterator (java.util.Iterator)8930 ArrayList (java.util.ArrayList)2267 Set (java.util.Set)1895 HashMap (java.util.HashMap)1828 Map (java.util.Map)1714 List (java.util.List)1622 HashSet (java.util.HashSet)1602 Test (org.junit.Test)624 IOException (java.io.IOException)524 Collection (java.util.Collection)377 Region (org.apache.geode.cache.Region)240 SSOException (com.iplanet.sso.SSOException)227 File (java.io.File)216 LinkedList (java.util.LinkedList)213 TreeSet (java.util.TreeSet)191 LinkedHashMap (java.util.LinkedHashMap)181 Entry (java.util.Map.Entry)174 SMSException (com.sun.identity.sm.SMSException)169 ListIterator (java.util.ListIterator)146 TreeMap (java.util.TreeMap)145