List of usage examples for org.apache.commons.collections15.set ListOrderedSet ListOrderedSet
public ListOrderedSet()
ListOrderedSet
using a HashSet
and an ArrayList
internally. From source file:annis.gui.QueryController.java
public QueryController(SearchUI ui) { this.ui = ui; this.history = new ListOrderedSet<HistoryEntry>(); }
From source file:com.javaid.bolaky.carpool.service.acl.userregistration.impl.UserRegistrationAclTranslator.java
public static Set<CarPoolError> convertToCarPoolErrorCodes(Set<PersonErrorCode> personErrorCodes) { Set<CarPoolError> carPoolErrorCodes = null; if (personErrorCodes != null && !personErrorCodes.isEmpty()) { carPoolErrorCodes = new ListOrderedSet<CarPoolError>(); for (PersonErrorCode personErrorCode : personErrorCodes) { CarPoolError carPoolError = CarPoolError.convertFrom(personErrorCode); if (carPoolError != null) { carPoolErrorCodes.add(carPoolError); }//from w w w. j a v a 2s . c om } } return carPoolErrorCodes; }
From source file:com.oltpbenchmark.util.TestCollectionUtil.java
/** * testPop//from w ww . ja v a2s . com */ @SuppressWarnings("unchecked") public void testPop() { String expected[] = new String[11]; RandomGenerator rng = new RandomGenerator(0); for (int i = 0; i < expected.length; i++) { expected[i] = rng.astring(1, 32); } // FOR Collection<String> collections[] = new Collection[] { CollectionUtil.addAll(new ListOrderedSet<String>(), expected), CollectionUtil.addAll(new HashSet<String>(), expected), CollectionUtil.addAll(new ArrayList<String>(), expected), }; for (Collection<String> c : collections) { assertNotNull(c); assertEquals(c.getClass().getSimpleName(), expected.length, c.size()); String pop = CollectionUtil.pop(c); assertNotNull(c.getClass().getSimpleName(), pop); assertEquals(c.getClass().getSimpleName(), expected.length - 1, c.size()); assertFalse(c.getClass().getSimpleName(), c.contains(pop)); if (c instanceof List || c instanceof ListOrderedSet) { assertEquals(c.getClass().getSimpleName(), expected[0], pop); } } // FOR }
From source file:edu.brown.utils.UniqueCombinationIterator.java
/** * Find the next unique combination/*from www. jav a 2 s. c o m*/ */ private void getNext() { assert (this.next == null); final boolean trace = LOG.isTraceEnabled(); final boolean debug = LOG.isDebugEnabled(); if (debug) LOG.debug("Finding next combination [call=" + (this.attempt_ctr++) + "]"); boolean valid = false; Vector<Integer> buffer = null; for (int i = this.last.get(0); i < this.num_elements; i++) { if (trace) LOG.trace("\n" + this); buffer = new Vector<Integer>(); buffer.setSize(this.combo_size); buffer.set(0, i); // We have a new combination! if (this.calculateCombinations(buffer, 1)) { if (trace) LOG.trace("Found new combination: " + buffer); valid = true; break; } if (trace) LOG.trace("No combination found that starts with index #" + i); buffer = null; this.initializeLast(i + 1); } // FOR if (trace) LOG.trace("VALID = " + valid); if (valid) { assert (this.combo_size == buffer.size()); this.next = new ListOrderedSet<E>(); for (int i = 0; i < this.combo_size; i++) { this.next.add(this.data.get(buffer.get(i))); } // FOR if (trace) LOG.trace("NEXT = " + this.next); // Increase the last position's counter so that it is different next // time this.last.set(this.combo_size - 1, this.last.lastElement() + 1); if (trace) LOG.trace("NEW LAST = " + this.last); this.finished = false; } else { this.finished = true; } }
From source file:edu.brown.utils.TestCollectionUtil.java
/** * testPop/* www .j a va 2 s . co m*/ */ @SuppressWarnings("unchecked") public void testPop() { String expected[] = new String[11]; DefaultRandomGenerator rng = new DefaultRandomGenerator(); for (int i = 0; i < expected.length; i++) { expected[i] = rng.astring(1, 32); } // FOR Collection<String> collections[] = new Collection[] { CollectionUtil.addAll(new ListOrderedSet<String>(), expected), CollectionUtil.addAll(new HashSet<String>(), expected), CollectionUtil.addAll(new ArrayList<String>(), expected), }; for (Collection<String> c : collections) { assertNotNull(c); assertEquals(c.getClass().getSimpleName(), expected.length, c.size()); String pop = CollectionUtil.pop(c); assertNotNull(c.getClass().getSimpleName(), pop); assertEquals(c.getClass().getSimpleName(), expected.length - 1, c.size()); assertFalse(c.getClass().getSimpleName(), c.contains(pop)); if (c instanceof List || c instanceof ListOrderedSet) { assertEquals(c.getClass().getSimpleName(), expected[0], pop); } } // FOR }
From source file:com.javaid.bolaky.carpool.service.acl.pools.impl.PoolsAclTranslator.java
public static Set<CarPoolError> convertToCarPoolErrors(Set<PoolsError> poolsErrors) { Set<CarPoolError> carPoolErrors = null; if (poolsErrors != null && !poolsErrors.isEmpty()) { carPoolErrors = new ListOrderedSet<CarPoolError>(); for (PoolsError poolsError : poolsErrors) { CarPoolError carPoolError = CarPoolError.convertFrom(poolsError); if (carPoolError != null) { carPoolErrors.add(carPoolError); }// w w w.j a va 2s .c om } } return carPoolErrors; }
From source file:com.javaid.bolaky.carpool.service.acl.pools.impl.PoolsAclTranslator.java
public static Set<PoolSearchResultVO> convert(List<Pool> pools) { Set<PoolSearchResultVO> poolSearchResultVOs = new ListOrderedSet<PoolSearchResultVO>(); if (pools != null && !pools.isEmpty()) { for (Pool pool : pools) { poolSearchResultVOs.add(PoolsAclTranslator.convert(pool)); }/*from www . ja v a2 s . c o m*/ } return poolSearchResultVOs; }
From source file:com.javaid.bolaky.domain.userregistration.entity.Person.java
public Set<PersonErrorCode> validate(@SuppressWarnings("rawtypes") Class... clazz) { Set<PersonErrorCode> personErrorCodes = new ListOrderedSet<PersonErrorCode>(); ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<Person>> constraintViolations = validator.validate(this, clazz); for (ConstraintViolation<Person> constraintViolation : constraintViolations) { personErrorCodes.add(PersonErrorCode.convertFrom(constraintViolation.getMessage())); }/*from w ww.ja v a 2s . co m*/ return UnmodifiableSet.decorate(personErrorCodes); }
From source file:com.javaid.bolaky.domain.pools.entity.Pool.java
private Set<PoolsError> validate() { Set<PoolsError> poolsErrors = new ListOrderedSet<PoolsError>(); ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Set<ConstraintViolation<Pool>> constraintViolations = validator.validate(this, MandatoryDataRules.class); for (ConstraintViolation<Pool> constraintViolation : constraintViolations) { poolsErrors.add(PoolsError.getPoolsError(constraintViolation.getMessage())); }/*from w w w . j a v a2 s . c o m*/ return UnmodifiableSet.decorate(poolsErrors); }
From source file:com.javaid.bolaky.carpool.service.acl.pools.impl.PoolsAclTranslator.java
public static Set<PoolVO> convertToPoolVOs(List<Pool> pools) { Set<PoolVO> poolVOs = new ListOrderedSet<PoolVO>(); if (pools != null && !pools.isEmpty()) { for (Pool pool : pools) { poolVOs.add(convertToPoolVO(pool)); }/*from w w w .j a va 2 s . co m*/ } return poolVOs; }