Skip to content
Permalink
Browse files
GEOMETRY-142: adding PointMap and PointSet implementations
  • Loading branch information
darkma773r committed Mar 18, 2022
1 parent 02b0263 commit 6c6d046532ab6c0c5cd670aaa4dc9ad384190d97
Showing 46 changed files with 10,336 additions and 39 deletions.
@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.geometry.core.collection;

import java.util.Map;

import org.apache.commons.geometry.core.Point;

/** {@link Map} type that uses points as keys. This interface is intended for
* use in cases where effectively equivalent (but not necessarily equal) points must
* map to the same entry. As such, this interface breaks the strict contract for
* {@link Map} where key equality is consistent with {@link Object#equals(Object)}.
* @param <P> Point type
* @param <V> Value type
*/
public interface PointMap<P extends Point<P>, V> extends Map<P, V> {

/** Get the map entry with a key equivalent to {@code pt} or {@code null}
* if no such entry exists. The returned instance supports use of
* the {@link Map.Entry#setValue(Object)} method to modify the
* mapping.
* @param pt point to fetch the map entry for
* @return map entry for the given point or null if no such entry
* exists
*/
Map.Entry<P, V> getEntry(P pt);
}
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.geometry.core.collection;

import java.util.Set;

import org.apache.commons.geometry.core.Point;

/** {@link Set} containing {@link Point} values. This interface is intended for
* use in cases where effectively equivalent (but not necessarily equal) points must
* be considered as equal by the set. As such, this interface breaks the strict contract
* for {@link Set} where membership is consistent with {@link Object#equals(Object)}.
* @param <P> Point type
*/
public interface PointSet<P extends Point<P>> extends Set<P> {

/** Get the set entry equivalent to {@code pt} or null if no
* such entry exists.
* @param pt point to find an equivalent for
* @return set entry equivalent to {@code pt} or null if
* no such entry exists
*/
P get(P pt);
}
@@ -0,0 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** This package contains core geometric collection types. */
package org.apache.commons.geometry.core.collection;

0 comments on commit 6c6d046

Please sign in to comment.