• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MutableList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.gs.collections.api.list.MutableList的典型用法代码示例。如果您正苦于以下问题:Java MutableList类的具体用法?Java MutableList怎么用?Java MutableList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MutableList类属于com.gs.collections.api.list包,在下文中一共展示了MutableList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getCityInName

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private CityRegion getCityInName(MutableList<String> entityNameList, MutableMultimap<String, CityRegion> cityMap){
    for(String token : entityNameList){
        if(cityMap.containsKey(token)){
            MutableList<String> entityNameSubList = entityNameList.subList(entityNameList.indexOf(token), entityNameList.size());
            MutableList<CityRegion> possibleMatches = cityMap.get(token).toList();
            CityRegion bestMatch = null;
            int missingCount = Integer.MAX_VALUE;
            for(CityRegion cityRegion : possibleMatches){
                String [] splitName = cityRegion.getName().split(" ");
                if(entityNameSubList.size() >= splitName.length){
                    MutableList<String> entityNameSubSubList = entityNameSubList.subList(0, splitName.length);
                    if(entityNameSubSubList.containsAll(FastList.newListWith(splitName))){
                        if (entityNameSubList.size() - splitName.length < missingCount) {
                            missingCount = entityNameSubList.size() - splitName.length;
                            bestMatch = cityRegion;
                        }
                    }
                }
            }
            return bestMatch;
        }
    }
    return null;
}
 
开发者ID:mdonigian,项目名称:Crocodilopolis,代码行数:25,代码来源:RegionIdentifier.java


示例2: testQ4

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
@Test
public void testQ4()
{
    CustomerAccountList accountsBefore = CustomerAccountFinder.findMany(CustomerAccountFinder.all());
    CustomerList customersBefore = CustomerFinder.findMany(CustomerFinder.all());
    accountsBefore.forceResolve(); //to get this list resolved before we add the new customer.
    customersBefore.forceResolve();

    MutableList<Pair<String, String>> accountDescriptionAndTypePairs = FastList.newListWith(
            Tuples.pair("Tom's saving Account", "Savings"),
            Tuples.pair("Tom's running Account", "Running")
    );

    this.addCustomerAccounts("Tom Jones", "UK", accountDescriptionAndTypePairs);

    CustomerAccountList accountsAfter = CustomerAccountFinder.findMany(CustomerAccountFinder.all());
    CustomerList customersAfter = CustomerFinder.findMany(CustomerFinder.all());

    Assert.assertEquals(1, customersAfter.size() - customersBefore.size());
    Assert.assertEquals(2, accountsAfter.size() - accountsBefore.size());

    Customer tom = CustomerFinder.findOne(CustomerFinder.name().eq("Tom Jones"));
    CustomerAccountList tomsAccounts = new CustomerAccountList(CustomerAccountFinder.customerId().eq(tom.getCustomerId()));
    Verify.assertSize(2, tomsAccounts);
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:26,代码来源:ExercisesRelationships.java


示例3: getFileList

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private static MutableList<Employee> getFileList()
{
    Timestamp currentTimestamp = Timestamp.valueOf("2015-02-01 00:00:00.0");

    Employee mary = new Employee(currentTimestamp, 1, "Mary", "Lamb", 26);
    Employee bob = new Employee(currentTimestamp, 2, "Bob", "Smith", 29);
    Employee ted = new Employee(currentTimestamp, 3, "Ted", "Smith", 33);
    Employee jake = new Employee(currentTimestamp, 4, "Jake", "Snake", 42);
    Employee barry = new Employee(currentTimestamp, 5, "Barry", "Bird", 28);
    Employee terry = new Employee(currentTimestamp, 6, "Terry", "Chase", 19);
    Employee harry = new Employee(currentTimestamp, 7, "Harry", "White", 22);
    Employee john = new Employee(currentTimestamp, 8, "John", "Doe", 45);
    Employee jane = new Employee(currentTimestamp, 9, "Jane", "Wilson", 28);

    return FastList.newListWith(mary, bob, ted, jake, barry, terry, harry, john, jane);
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:17,代码来源:ExercisesMTLoader.java


示例4: compileMutableFieldEnum

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
public void compileMutableFieldEnum() {
    final MutableList<Field> fields = dt_.getFields().select(fieldsByModifierPredicate(FieldModifier.val));
    out();
    out(2, "private static enum " + BF + " {");

    for (int i = 0; i < fields.size(); i++) {
        final Field field = fields.get(i);
        if (i + 1 < fields.size()) {
            out(3, field.getName() + ",");
        }
        else {
            out(3, field.getName());
        }
    }
    out(2, "}");
}
 
开发者ID:kaaprotech,项目名称:satu,代码行数:17,代码来源:ModelBuilderCompiler.java


示例5: compileFieldEnum

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
public void compileFieldEnum() {
    final MutableList<Field> fields = dt_.getFields().select(fieldsByModifierPredicate(FieldModifier.val));
    out();
    out(3, "private static enum " + DBF + " {");
    out(4, DT + (fields.notEmpty() ? "," : ""));
    for (int i = 0; i < fields.size(); i++) {
        final Field field = fields.get(i);
        if (i + 1 < fields.size()) {
            out(4, field.getName() + ",");
        }
        else {
            out(4, field.getName());
        }
    }
    out(3, "}");
}
 
开发者ID:kaaprotech,项目名称:satu,代码行数:17,代码来源:ModelDeltaBuilderCompiler.java


示例6: calculateRecommendations

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
public MutableMap<Integer, MutableList<Integer>> calculateRecommendations() {
    ListMultimap<Integer, Purchases.Purchase> buysByUser =
            ListIterate.groupBy(purchases.getPurchases(), Purchases.Purchase::getUserId);

    MutableMap<Integer, MutableIntBag> productSimilarity =
            buysByUser.multiValuesView()
                    .flatCollect(this::gsCombinations)
                    .groupBy(CoBuy::getProductId1)
                    .keyMultiValuePairsView()
                    .toMap((Pair<Integer, ?> pair) -> pair.getOne(),
                            pair -> pair.getTwo().asLazy()
                                    .collectInt(CoBuy::getProductId2).toBag());

    return productSimilarity.keyValuesView()
            .toMap(pair -> pair.getOne(),
                    pair -> gsKeys(pair.getTwo()));
}
 
开发者ID:Adopt-a-JSR,项目名称:java-8-benchmarks,代码行数:18,代码来源:GSLambdaRecommendations.java


示例7: getCityRegionNonUS

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
public String getCityRegionNonUS(String entityName, String country){
    MutableList<String> entityNameList = generateEntityNameList(entityName);
    try {
        CityRegion cityRegion = getCityInName(entityNameList, regionalData.getCountries().get(country).getCityMap());
        if (cityRegion == null) {
            return null;
        }
        return cityRegion.getName();
    }catch(NullPointerException e){
        return null;
    }
}
 
开发者ID:mdonigian,项目名称:Crocodilopolis,代码行数:13,代码来源:RegionIdentifier.java


示例8: getCityRegionUS

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
public String getCityRegionUS(String entityName, String stateProvince, String country){
    MutableList<String> entityNameList = generateEntityNameList(entityName);
    try{
        CityRegion cityRegion = getCityInName(entityNameList, regionalData.getCountries().get(country).getStateProvinceMap().get(stateProvince).getCityMap());
        if(cityRegion == null){
            return null;
        }
        return cityRegion.getName();
    }catch(NullPointerException e){
        return null;
    }
}
 
开发者ID:mdonigian,项目名称:Crocodilopolis,代码行数:13,代码来源:RegionIdentifier.java


示例9: assertListContainsExactly

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private static <E, T> void assertListContainsExactly(List<E> list, Attribute<E, T> attribute, T... items)
{
    MutableList<T> actualValues = Lists.mutable.of();
    for (E e: list)
    {
        actualValues.add(attribute.valueOf(e));
    }

    assertEquals(items.length, actualValues.size());
    for (T item : items)
    {
        assertTrue("Expected to contain " + item + " but contains: " + actualValues.toString(), actualValues.contains(item));
    }
}
 
开发者ID:goldmansachs,项目名称:reladomo,代码行数:15,代码来源:CacheLoaderManagerProcessingOnlyTest.java


示例10: testQ2

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
@Test
public void testQ2()
{
    MutableList accountNameAndTypes = FastList.newListWith(
            Tuples.twin("John's Saving Account 2", "Savings"),
            Tuples.twin("My Account", "Running"),
            Tuples.twin("No customer Account", "Virtual")
    );

    CustomerAccountList accounts = this.getAccountsBasedOnTuples(accountNameAndTypes);

    Verify.assertListsEqual(FastList.newListWith(300, 500, 600),
            accounts.asGscList().collect(CustomerAccountFinder.accountId()));
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:15,代码来源:ExercisesAdvancedFinder.java


示例11: getAttributeValuesForObjects

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
public MutableList<Object> getAttributeValuesForObjects(
        final MithraObject mithraObject,
        Attribute... attributes)
{
    Assert.fail("Implement this functionality to make the test pass");
    return null;
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:8,代码来源:ExercisesAdvancedFinder.java


示例12: testQ13

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
@Test
public void testQ13()
{
    Person ada = PersonFinder.findOne(PersonFinder.personId().eq(8));

    MutableList<Object> adaAttrs
            = this.getAttributeValuesForObjects(ada, PersonFinder.age(), PersonFinder.personId(), PersonFinder.name());

    Verify.assertListsEqual(FastList.newListWith(24, 8, "Ada Lovelace"), adaAttrs);

    Person douglas = PersonFinder.findOne(PersonFinder.personId().eq(9));

    MutableList<Object> douglasAttrs
            = this.getAttributeValuesForObjects(douglas, PersonFinder.age(), PersonFinder.name());

    Verify.assertListsEqual(FastList.newListWith(42, "Douglas Adams"), douglasAttrs);

    // Now use the exact same method for a different Mithra Object and set of attributes.
    CustomerAccount virtual = CustomerAccountFinder.findOne(CustomerAccountFinder.accountId().eq(600));

    MutableList<Object> virtualAttrs
            = this.getAttributeValuesForObjects(virtual,
            CustomerAccountFinder.customerId(),
            CustomerAccountFinder.accountType(),
            CustomerAccountFinder.accountName());

    Verify.assertListsEqual(FastList.newListWith(999, "Virtual", "No customer Account"), virtualAttrs);
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:29,代码来源:ExercisesAdvancedFinder.java


示例13: testQ8a

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
@Test
public void testQ8a()
{
    Timestamp mid2008 = Timestamp.valueOf("2008-06-01 00:00:00.0");
    MutableList<Customer> inDebt2008 = getCustomersWithNegativeNetBalanceInMemory(mid2008);
    Verify.assertListsEqual(FastList.newListWith("Diana Prince"),
            inDebt2008.collect(CustomerFinder.name()));

    Timestamp now = new Timestamp(System.currentTimeMillis());
    MutableList<Customer> inDebtNow = getCustomersWithNegativeNetBalanceInMemory(now);
    Verify.assertSetsEqual(UnifiedSet.newSetWith("Diana Prince", "Claire Bennet", "Yusuke Sato"),
            inDebtNow.collect(CustomerFinder.name()).toSet());
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:14,代码来源:ExercisesBiTemporal.java


示例14: loadAllPetData

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
/**
 * This represents a classic case of data loading. Take a look at {@link Exercise4Test#getInputPetList()}.
 * It has the new data which needs to be loaded.
 * <p>
 * Use {@link com.gs.fw.common.mithra.util.MithraMultiThreadedLoader}.
 * {@code Executor}s are already created for your convenience.
 * You only need to create the {@link com.gs.fw.common.mithra.mtloader.MatcherThread}, {@link com.gs.fw.common.mithra.mtloader.DbLoadThread}.
 * {@code PetList} is the list of current {@code Pet}s
 * </p>
 * Replace the nulls with appropriate inputs.
 */
@Test
public void loadAllPetData() throws AbortException
{
    MutableList<Pet> inputPetList = this.getInputPetList();

    SingleQueueExecutor singleQueueExecutor = new SingleQueueExecutor(
            1,
            PetFinder.petName().ascendingOrderBy(),
            1,
            PetFinder.getFinderInstance(),
            1);

    MatcherThread<Pet> matcherThread = null;
    matcherThread.start();

    PetList dbList = null;
    DbLoadThread dbLoadThread = null;
    dbLoadThread.start();

    matcherThread.addFileRecords(null);
    matcherThread.setFileDone();
    matcherThread.waitTillDone();

    Verify.assertSize(8,
            PetFinder.findMany(PetFinder.processingDate().eq(TimestampProvider.getPreviousDay(TimestampProvider.getCurrentDate()))));
    Verify.assertSize(8, PetFinder.findMany(PetFinder.all()));
    Verify.assertSize(1, PetFinder.findMany(PetFinder.petName().eq("Serpy")));
    Verify.assertEmpty(PetFinder.findMany(PetFinder.petName().eq("Wuzzy").or(PetFinder.petName().eq("Speedy"))));
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:41,代码来源:Exercise4Test.java


示例15: getInputPetList

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private MutableList<Pet> getInputPetList()
{
    Pet tabby = new Pet("Tabby", 1, 4, 1); // Tabby's age has changed
    Pet spot = new Pet("Spot", 1, 17, 2); // Spot's owner has changed
    Pet dolly = new Pet("Dolly", 3, 4, 1); // Dolly's owner and age has changed
    Pet spike = new Pet("Spike", 3, 5, 2); // Spike's age has changed
    Pet tweety = new Pet("Tweety", 6, 2, 4); // Tweety's age has changed
    Pet fuzzy = new Pet("Fuzzy", 7, 1, 6); // Fuzzy is unchanged
    Pet serpy = new Pet("Serpy", 4, 50, 6); // Serpy was milestoned before, but now is coming again
    Pet chirpy = new Pet("Chirpy", 2, 2, 4); // Chirpy is newly added to the Pet family
    // Wuzzy and Speedy are not coming, we need to milestone them.

    return Lists.mutable.with(tabby, spot, dolly, spike, tweety, fuzzy, serpy, chirpy);
}
 
开发者ID:goldmansachs,项目名称:reladomo-kata,代码行数:15,代码来源:Exercise4Test.java


示例16: sortTest

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private static void sortTest() {
    List<String> jdk = Lists.newArrayList("a1", "a2", "a3", "a1");
    Iterable<String> iterable = jdk;
    MutableList<String> gs = FastList.newList(jdk);

    // sorting
    Collections.sort(jdk); // using jdk
    List<String> guava = Ordering.natural().sortedCopy(iterable); // using guava
    gs.sortThis(); // using gs

    System.out.println("sort = " + jdk + ":" + guava + ":" + gs); // print sort = [a1, a1, a2, a3]:[a1, a1, a2, a3]:[a1, a1, a2, a3]
}
 
开发者ID:Vedenin,项目名称:java_in_examples,代码行数:13,代码来源:JavaTransformTest.java


示例17: testBinarySearch

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private static void testBinarySearch() {
    List<String> list = Lists.newArrayList("2", "4", "13", "31", "43");
    MutableList<String> mutableList = FastList.newListWith("2", "4","13", "31", "43");

    // find element in sorted list
    int jdk = Collections.binarySearch(list, "13");
    int guava = Ordering.natural().binarySearch(list, "13");
    int gs = mutableList.binarySearch("13");

    System.out.println("find = " + jdk + ":" + guava + ":" + gs); // print find = 2:2:2
}
 
开发者ID:Vedenin,项目名称:java_in_examples,代码行数:12,代码来源:CollectionSearchTests.java


示例18: testSearch

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private static void testSearch() {
    Collection<String> collection = Lists.newArrayList("2", "14", "3", "13", "43");
    MutableList<String> mutableList = FastList.newListWith("2", "14", "3", "13", "43");
    Iterable<String> iterable = collection;

    // find element in unsorted collection
    String jdk = collection.stream().filter("13"::equals).findFirst().get();
    String guava = Iterables.find(iterable, "13"::equals);
    String apache = CollectionUtils.find(iterable, "13"::equals);
    String gs = mutableList.select("13"::equals).get(0);

    System.out.println("find = " + jdk + ":" + guava + ":" + apache + ":" + gs); // print find = 13:13:13:13
}
 
开发者ID:Vedenin,项目名称:java_in_examples,代码行数:14,代码来源:CollectionSearchTests.java


示例19: sortTest

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private static void sortTest() {
    List<String> jdk = Lists.newArrayList("a1", "a2", "a3", "a1");
    Iterable<String> iterable = jdk;
    MutableList<String> gs = FastList.newList(jdk);

    // сортировка
    Collections.sort(jdk); // с помощью jdk
    List<String> guava = Ordering.natural().sortedCopy(iterable); // с помощью guava
    gs.sortThis(); // с помощью gs

    System.out.println("sort = " + jdk + ":" + guava + ":" + gs); // напечатает sort = [a1, a1, a2, a3]:[a1, a1, a2, a3]:[a1, a1, a2, a3]
}
 
开发者ID:Vedenin,项目名称:java_in_examples,代码行数:13,代码来源:JavaTransformTest.java


示例20: testBinarySearch

import com.gs.collections.api.list.MutableList; //导入依赖的package包/类
private static void testBinarySearch() {
    List<String> list = Lists.newArrayList("2", "4", "13", "31", "43");
    MutableList<String> mutableList = FastList.newListWith("2", "4","13", "31", "43");

    // найти элемент в отсортированом списке
    int jdk = Collections.binarySearch(list, "13");
    int guava = Ordering.natural().binarySearch(list, "13");
    int gs = mutableList.binarySearch("13");

    System.out.println("find = " + jdk + ":" + guava + ":" + gs); // напечатает find = 2:2:2
}
 
开发者ID:Vedenin,项目名称:java_in_examples,代码行数:12,代码来源:CollectionSearchTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BoilerpipeExtractor类代码示例发布时间:2022-05-23
下一篇:
Java PsiClassInitializer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap