List of usage examples for java.util AbstractSet contains
boolean contains(Object o);
From source file:gate.creole.tokeniser.SimpleTokeniser.java
/** * Converts the finite state machine to a deterministic one. * * @param s/* w w w.j a va 2 s. com*/ */ private AbstractSet<FSMState> lambdaClosure(Set<FSMState> s) { //the stack/queue used by the algorithm LinkedList<FSMState> list = new LinkedList<FSMState>(s); //the set to be returned AbstractSet<FSMState> lambdaClosure = new HashSet<FSMState>(s); FSMState top; FSMState currentState; Set<FSMState> nextStates; Iterator<FSMState> statesIter; while (!list.isEmpty()) { top = list.removeFirst(); nextStates = top.nextSet(null); if (null != nextStates) { statesIter = nextStates.iterator(); while (statesIter.hasNext()) { currentState = statesIter.next(); if (!lambdaClosure.contains(currentState)) { lambdaClosure.add(currentState); list.addFirst(currentState); } //if(!lambdaClosure.contains(currentState)) } //while(statesIter.hasNext()) } //if(null != nextStates) } return lambdaClosure; }
From source file:org.apache.cassandra.io.compress.CompressionParameters.java
private static ICompressor createCompressor(Class<?> compressorClass, Map<String, String> compressionOptions) throws ConfigurationException { if (compressorClass == null) { if (!compressionOptions.isEmpty()) throw new ConfigurationException("Unknown compression options (" + compressionOptions.keySet() + ") since no compression class found"); return null; }// w ww . ja v a2 s .co m try { Method method = compressorClass.getMethod("create", Map.class); ICompressor compressor = (ICompressor) method.invoke(null, compressionOptions); // Check for unknown options AbstractSet<String> supportedOpts = Sets.union(compressor.supportedOptions(), GLOBAL_OPTIONS); for (String provided : compressionOptions.keySet()) if (!supportedOpts.contains(provided)) throw new ConfigurationException("Unknown compression options " + provided); return compressor; } catch (NoSuchMethodException e) { throw new ConfigurationException("create method not found", e); } catch (SecurityException e) { throw new ConfigurationException("Access forbiden", e); } catch (IllegalAccessException e) { throw new ConfigurationException("Cannot access method create in " + compressorClass.getName(), e); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); throw new ConfigurationException(String.format("%s.create() threw an error: %s", compressorClass.getSimpleName(), cause == null ? e.getClass().getName() + " " + e.getMessage() : cause.getClass().getName() + " " + cause.getMessage()), e); } catch (ExceptionInInitializerError e) { throw new ConfigurationException("Cannot initialize class " + compressorClass.getName()); } }