All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.whitbeck.rdbparser.SortedSetAsZipList Maven / Gradle / Ivy

There is a newer version: 2.1.0
Show newest version
/**
 * Copyright (c) 2015-2018 John Whitbeck. All rights reserved.
 *
 * 

The use and distribution terms for this software are covered by the * Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) * which can be found in the file al-v20.txt at the root of this distribution. * By using this software in any fashion, you are agreeing to be bound by * the terms of this license. * *

You must not remove this notice, or any other, from this software. */ package net.whitbeck.rdbparser; import java.nio.charset.Charset; import java.util.Arrays; import java.util.List; import java.util.ListIterator; final class SortedSetAsZipList implements LazyList { private static final Charset ASCII = Charset.forName("ASCII"); private static final byte[] POS_INF_BYTES = "inf".getBytes(ASCII); private static final byte[] NEG_INF_BYTES = "-inf".getBytes(ASCII); private static final byte[] NAN_BYTES = "nan".getBytes(ASCII); private final byte[] envelope; SortedSetAsZipList(byte[] envelope) { this.envelope = envelope; } @Override public List get() { List values = new ZipList(envelope).get(); // fix the "+inf", "-inf", and "nan" values for (ListIterator i = values.listIterator(); i.hasNext(); ) { byte[] val = i.next(); if (Arrays.equals(val, POS_INF_BYTES)) { i.set(DoubleBytes.POSITIVE_INFINITY); } else if (Arrays.equals(val, NEG_INF_BYTES)) { i.set( DoubleBytes.NEGATIVE_INFINITY); } else if (Arrays.equals(val, NAN_BYTES)) { i.set(DoubleBytes.NaN); } } return values; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy