Skip to content

Commit

Permalink
remove fastutil dependency (#576)
Browse files Browse the repository at this point in the history
Removes the heavy (19MB) dependency on fastutil by directly including only the used classes directly into chartfx.

* shades fastutil classes
* removes all unused methods from the classes
* removes fastutil dependency
* adds stream support
  • Loading branch information
ennerf committed Apr 4, 2023
1 parent 8d349d9 commit ed41b3a
Show file tree
Hide file tree
Showing 12 changed files with 1,584 additions and 13 deletions.
5 changes: 0 additions & 5 deletions chartfx-dataset/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
</description>

<dependencies>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>8.3.1</version>
</dependency>
<!-- micro-benchmarking framework -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.fair_acc.dataset.DataSet2D;
import io.fair_acc.dataset.EditableDataSet;

import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import io.fair_acc.dataset.spi.fastutil.DoubleArrayList;

/**
* Implementation of the {@code DataSet} interface which stores x,y values in two separate arrays. It provides methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.fair_acc.dataset.DataSetError;
import io.fair_acc.dataset.EditableDataSet;

import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import io.fair_acc.dataset.spi.fastutil.DoubleArrayList;

/**
* Implementation of the {@code DataSetError} interface which stores x,y, +eyn, and -eyn values in separate double
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.fair_acc.dataset.DataSet2D;
import io.fair_acc.dataset.EditableDataSet;

import it.unimi.dsi.fastutil.floats.FloatArrayList;
import io.fair_acc.dataset.spi.fastutil.FloatArrayList;

/**
* Implementation of the <code>DataSet</code> interface which stores x,y values in two separate arrays. It provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.fair_acc.dataset.DataSet;
import io.fair_acc.dataset.EditableDataSet;

import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import io.fair_acc.dataset.spi.fastutil.DoubleArrayList;

/**
* Implementation of the {@code DataSet} interface which stores x,y,... values in nDim separate arrays. It provides
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.fair_acc.dataset.spi.fastutil;

/**
* Utilities for shading fastutil lists.
*/
class ArrayUtil {

/** Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array of given length.
*
* <p>This method may be used whenever an array range check is needed.
*
* @param arrayLength an array length.
* @param from a start index (inclusive).
* @param to an end index (inclusive).
* @throws IllegalArgumentException if {@code from} is greater than {@code to}.
* @throws ArrayIndexOutOfBoundsException if {@code from} or {@code to} are greater than {@code arrayLength} or negative.
*/
public static void ensureFromTo(final int arrayLength, final int from, final int to) {
if (from < 0) throw new ArrayIndexOutOfBoundsException("Start index (" + from + ") is negative");
if (from > to) throw new IllegalArgumentException("Start index (" + from + ") is greater than end index (" + to + ")");
if (to > arrayLength) throw new ArrayIndexOutOfBoundsException("End index (" + to + ") is greater than array length (" + arrayLength + ")");
}

public static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;

}
Loading

0 comments on commit ed41b3a

Please sign in to comment.