-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Java seems not to have an abstraction of numbers or arithmetic values.
I first thought that the class Numbers would fill this role and designed a WeightedEdge<V, W extends Number> like this
public interface WeightedEdge<V, W extends Number> {
W weight();
}but this does not allow to formulate calculations with the weights, i.e. something like
public interface WeightedPath<V, E extends WeightedEdge<V, W>, W extends Number>
extends Path<V, E> {
default W distance() {
// Problem: Number.plus() does not exist
return edges().reduce((sum, edge) -> sum.plus(edge.weight()));
}
}So do we have to declare WeightedEdge to always use double for weights??
Reactions are currently unavailable