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


Java IndexedCollection.removeAll方法代码示例

本文整理汇总了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());
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:17,代码来源:DiskPersistenceTest.java

示例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!
    }
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:35,代码来源:TransactionalIndexedCollectionDemo.java

示例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);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:16,代码来源:OffHeapPersistenceTest.java


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