本文整理汇总了Java中org.pcollections.HashTreePMap类的典型用法代码示例。如果您正苦于以下问题:Java HashTreePMap类的具体用法?Java HashTreePMap怎么用?Java HashTreePMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HashTreePMap类属于org.pcollections包,在下文中一共展示了HashTreePMap类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEmpty
import org.pcollections.HashTreePMap; //导入依赖的package包/类
public void testEmpty() {
PMap<?,?> empty = HashTreePMap.empty();
UtilityTest.assertEqualsAndHash(new HashMap<Object,Object>(), empty);
assertEquals(0, empty.size());
assertTrue(empty.isEmpty());
for(@SuppressWarnings("unused") Object e : empty.entrySet())
fail();
}
示例2: hasCycle
import org.pcollections.HashTreePMap; //导入依赖的package包/类
public static <T, K> boolean hasCycle(Forest<T, K> forest) {
Checks.checkNotNull(forest, "forest must not be null");
PMap<K, Node<T, K>> seen = HashTreePMap.empty();
return forest
.getAllNodes()
.values()
.stream()
.anyMatch(node -> hasCycle(node, seen));
}
示例3: of
import org.pcollections.HashTreePMap; //导入依赖的package包/类
public static Record of(Stream<Value> values) {
/*
* Collectors.toMap will call HashMap.merge() which will throw a NullPointerException if supplied with a null
* for the value parameter, so filter out null values first.
*/
return new HashRecord(HashTreePMap.from(values.filter(v -> null != v.value()).collect(Collectors.toMap(Value::key, Value::value))));
}
示例4: applyUnsafe
import org.pcollections.HashTreePMap; //导入依赖的package包/类
@Override
public PMap<String, V> applyUnsafe(JsonParser p) throws IOException {
Map<String, V> values = new HashMap<>();
if (p.nextToken() == JsonToken.END_OBJECT) {
return HashTreePMap.empty();
}
while (p.nextValue() != JsonToken.END_OBJECT) {
String fieldName = p.getCurrentName();
values.put(fieldName, valueDeserialiser.apply(p));
}
return HashTreePMap.from(values);
}
示例5: applyUnsafe
import org.pcollections.HashTreePMap; //导入依赖的package包/类
@Override
public PMap<String, T> applyUnsafe(BsonValue p) throws BsonInvalidOperationException {
BsonDocument doc = p.asDocument();
Map<String, T> values = new HashMap<>();
for (Map.Entry<String,BsonValue> e : doc.entrySet()) {
values.put(e.getKey(), valueDeserialiser.apply(e.getValue()));
}
return HashTreePMap.from(values);
}
示例6: testSingleton
import org.pcollections.HashTreePMap; //导入依赖的package包/类
public void testSingleton() {
UtilityTest.assertEqualsAndHash(HashTreePMap.empty().plus(10, "test"),
HashTreePMap.singleton(10, "test"));
}
示例7: PcollectionsSetBuilder
import org.pcollections.HashTreePMap; //导入依赖的package包/类
PcollectionsSetBuilder() {
super(MapPSet.from(HashTreePMap.empty()), set -> set::plus, PcollectionsSet::new);
}
示例8: PcollectionsMapBuilder
import org.pcollections.HashTreePMap; //导入依赖的package包/类
PcollectionsMapBuilder() {
super(HashTreePMap.empty(), map -> map::plus, PcollectionsMap::new);
}
示例9: of
import org.pcollections.HashTreePMap; //导入依赖的package包/类
default Value of(Map<String, ? extends T> values) {
return of(HashTreePMap.from(values));
}
示例10: dollar_methods
import org.pcollections.HashTreePMap; //导入依赖的package包/类
@Test public void
dollar_methods() {
Key<String> name = $("name");
Key<Integer> age = $("age");
MapKey<String> phoneNumbers = $M("phoneNumbers");
RecordKey address = $R("address");
ListKey<String> addressLines = $L("addressLines");
Key<String> postcode = $("postcode");
Record person = $$(
name.of("Peter Warlock"),
age.of(43));
Record numbers = $$(phoneNumbers.of(
"home", "01234 567890",
"work", "0208 1234567",
"mobile", "07771 234567"
));
Record personWithNumbers = $$(person, numbers);
Record completePerson = $$(personWithNumbers, address.of(
addressLines.of(
"23 Acacia Avenue",
"Sunderland"
),
postcode.of("VB6 5UX")
));
Map<String, String> expectedNumbers = new HashMap<>();
expectedNumbers.put("home", "01234 567890");
expectedNumbers.put("work", "0208 1234567");
expectedNumbers.put("mobile", "07771 234567");
assertThat(completePerson, ARecord.instance()
.with(name, "Peter Warlock")
.with(age, 43)
.with(phoneNumbers, HashTreePMap.from(expectedNumbers))
.with(address, $$(
addressLines.of("23 Acacia Avenue", "Sunderland"),
postcode.of("VB6 5UX")
)
));
}
示例11: forTable
import org.pcollections.HashTreePMap; //导入依赖的package包/类
public static TableMapping forTable(String tableName) {
return new TableMapping(tableName, HashTreePMap.empty());
}