本文整理汇总了Java中org.mapdb.Fun.COMPARATOR属性的典型用法代码示例。如果您正苦于以下问题:Java Fun.COMPARATOR属性的具体用法?Java Fun.COMPARATOR怎么用?Java Fun.COMPARATOR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.mapdb.Fun
的用法示例。
在下文中一共展示了Fun.COMPARATOR属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIndexes
@SuppressWarnings({"unchecked", "rawtypes"})
protected void createIndexes(DB database)
{
//HEIGHT INDEX
Tuple2Comparator<Integer, byte[]> comparator = new Fun.Tuple2Comparator<Integer, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("blocks_index_height")
.comparator(comparator)
.makeOrGet();
NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("blocks_index_height_descending")
.comparator(new ReverseComparator(comparator))
.makeOrGet();
createIndex(HEIGHT_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Integer, byte[], Block>() {
@Override
public Integer run(byte[] key, Block value) {
return value.getHeight();
}
});
}
示例2: createIndexes
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void createIndexes(DB database)
{
//TIMESTAMP INDEX
Tuple2Comparator<Long, byte[]> comparator = new Fun.Tuple2Comparator<Long, byte[]>(Fun.COMPARATOR, UnsignedBytes.lexicographicalComparator());
NavigableSet<Tuple2<Integer, byte[]>> heightIndex = database.createTreeSet("transactions_index_timestamp")
.comparator(comparator)
.makeOrGet();
NavigableSet<Tuple2<Integer, byte[]>> descendingHeightIndex = database.createTreeSet("transactions_index_timestamp_descending")
.comparator(new ReverseComparator(comparator))
.makeOrGet();
createIndex(TIMESTAMP_INDEX, heightIndex, descendingHeightIndex, new Fun.Function2<Long, byte[], Transaction>() {
@Override
public Long run(byte[] key, Transaction value) {
return value.getTimestamp();
}
});
}
示例3: nComparableComparators
private static Comparator[] nComparableComparators(int length) {
Comparator[] comparators = new Comparator[length];
for(int i=0;i<comparators.length;i++){
comparators[i] = Fun.COMPARATOR;
}
return comparators;
}