本文整理汇总了Java中com.googlecode.cqengine.IndexedCollection.removeAll方法的典型用法代码示例。如果您正苦于以下问题:Java IndexedCollection.removeAll方法的具体用法?Java IndexedCollection.removeAll怎么用?Java IndexedCollection.removeAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.cqengine.IndexedCollection
的用法示例。
在下文中一共展示了IndexedCollection.removeAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCompact
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void testCompact() {
DiskPersistence<Car, Integer> persistence = DiskPersistence.onPrimaryKey(Car.CAR_ID);
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>(persistence);
cars.addAll(CarFactory.createCollectionOfCars(100));
long bytesUsedWhenFullyPopulated = persistence.getBytesUsed();
Assert.assertTrue("Bytes used when fully populated should be greater than zero: " + bytesUsedWhenFullyPopulated, bytesUsedWhenFullyPopulated > 0);
cars.removeAll(CarFactory.createCollectionOfCars(100));
long bytesUsedWhenObjectsRemoved = persistence.getBytesUsed();
Assert.assertTrue("Bytes used when objects removed (" + bytesUsedWhenObjectsRemoved + ") should remain the same as when fully populated (" + bytesUsedWhenFullyPopulated + ")", bytesUsedWhenObjectsRemoved == bytesUsedWhenFullyPopulated);
persistence.compact(); // Truncates size of the database, but not to zero as the tables which were created remain (although empty)
long bytesUsedAfterCompaction = persistence.getBytesUsed();
Assert.assertTrue("Bytes used after compaction (" + bytesUsedAfterCompaction + ") should be less than when fully populated (" + bytesUsedWhenFullyPopulated + ")", bytesUsedAfterCompaction < bytesUsedWhenFullyPopulated);
Assert.assertTrue("Failed to delete temp file:" + persistence.getFile(), persistence.getFile().delete());
}
示例2: main
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create example Car objects...
Car car1 = CarFactory.createCar(1); // "Ford Fusion"
Car car2 = CarFactory.createCar(2); // "Ford Taurus"
Car car3 = CarFactory.createCar(3); // "Honda Civic"
Car car4 = CarFactory.createCar(4); // "Honda Accord"
// We will store the cars in TransactionalIndexedCollection, which provides MVCC support...
IndexedCollection<Car> cars = new TransactionalIndexedCollection<Car>(Car.class);
// ===== Examples of modifying the collection using MVCC transactions... =====
// Add 4 cars in a single transaction...
cars.addAll(asList(car1, car2, car3, car4));
// Remove 2 cars in a single transaction...
cars.removeAll(asList(car3, car4));
// Replace 1 car with 2 other cars in a single transaction...
cars.update(asList(car2), asList(car3, car4));
// ===== Examples of querying the collection using MVCC transactions... =====
// Retrieve with READ_COMMITTED transaction isolation...
ResultSet<Car> results = cars.retrieve(equal(Car.MANUFACTURER, "Ford"));
try {
for (Car car : results) {
System.out.println(car); // prints car 1 ("Ford Fusion")
}
}
finally {
results.close(); // ..close the ResultSet when finished reading!
}
}
示例3: testCompact
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void testCompact() {
OffHeapPersistence<Car, Integer> persistence = OffHeapPersistence.onPrimaryKey(Car.CAR_ID);
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>(persistence);
cars.addAll(CarFactory.createCollectionOfCars(100));
long bytesUsedWhenFullyPopulated = persistence.getBytesUsed();
Assert.assertTrue("Bytes used when fully populated should be greater than zero: " + bytesUsedWhenFullyPopulated, bytesUsedWhenFullyPopulated > 0);
cars.removeAll(CarFactory.createCollectionOfCars(100));
long bytesUsedWhenObjectsRemoved = persistence.getBytesUsed();
Assert.assertTrue("Bytes used when objects removed (" + bytesUsedWhenObjectsRemoved + ") should remain the same as when fully populated (" + bytesUsedWhenFullyPopulated + ")", bytesUsedWhenObjectsRemoved == bytesUsedWhenFullyPopulated);
persistence.compact(); // Truncates size of the database, but not to zero as the tables which were created remain (although empty)
long bytesUsedAfterCompaction = persistence.getBytesUsed();
Assert.assertTrue("Bytes used after compaction (" + bytesUsedAfterCompaction + ") should be less than when fully populated (" + bytesUsedWhenFullyPopulated + ")", bytesUsedAfterCompaction < bytesUsedWhenFullyPopulated);
}