diff --git a/LICENSE.txt b/LICENSE.txt index 4010f5c..8aba810 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2017 - 2021, Howard Hughes Medical Institute. +Copyright (c) 2017 - 2023, Howard Hughes Medical Institute. All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/pom.xml b/pom.xml index 094fa85..553bf36 100644 --- a/pom.xml +++ b/pom.xml @@ -98,5 +98,13 @@ net.imglib2 imglib2 + + + + junit + junit + test + + diff --git a/src/main/java/net/imglib2/converter/longaccess/ARGBConverter.java b/src/main/java/net/imglib2/converter/longaccess/ARGBConverter.java index 0454341..7ee3114 100644 --- a/src/main/java/net/imglib2/converter/longaccess/ARGBConverter.java +++ b/src/main/java/net/imglib2/converter/longaccess/ARGBConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/longaccess/FloatConverter.java b/src/main/java/net/imglib2/converter/longaccess/FloatConverter.java index 7168822..c4d62ed 100644 --- a/src/main/java/net/imglib2/converter/longaccess/FloatConverter.java +++ b/src/main/java/net/imglib2/converter/longaccess/FloatConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/ARGBLongAccessTypeARGBTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/ARGBLongAccessTypeARGBTypeConverter.java index 4fe5019..6de19b3 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/ARGBLongAccessTypeARGBTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/ARGBLongAccessTypeARGBTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/ByteLongAccessTypeByteTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/ByteLongAccessTypeByteTypeConverter.java index cc5b866..5e90272 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/ByteLongAccessTypeByteTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/ByteLongAccessTypeByteTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/ByteLongAccessTypeNativeBoolTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/ByteLongAccessTypeNativeBoolTypeConverter.java new file mode 100644 index 0000000..902876e --- /dev/null +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/ByteLongAccessTypeNativeBoolTypeConverter.java @@ -0,0 +1,83 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.converter.readwrite.longaccess; + +import net.imglib2.Sampler; +import net.imglib2.converter.readwrite.SamplerConverter; +import net.imglib2.img.basictypeaccess.BooleanAccess; +import net.imglib2.img.basictypeaccess.ByteAccess; +import net.imglib2.type.logic.NativeBoolType; +import net.imglib2.type.numeric.integer.ByteLongAccessType; +import net.imglib2.type.numeric.integer.ByteType; + +/** + * A {@link SamplerConverter} that converts {@link ByteLongAccessType} into + * {@link NativeBoolType}. {@link NativeBoolType}s are fundamentally 8 bits, + * which is also the size of a {@link ByteType}; even sizes make this conversion + * sensical. + * + * @author Gabriel Selzer + */ +public class ByteLongAccessTypeNativeBoolTypeConverter implements SamplerConverter< ByteLongAccessType, NativeBoolType > +{ + + @Override + public NativeBoolType convert( final Sampler< ? extends ByteLongAccessType > sampler ) + { + return new NativeBoolType( new ConvertedAccess( sampler.get() ) ); + } + + public static class ConvertedAccess implements BooleanAccess + { + private static final byte ONE = ( byte ) 1; + + private static final byte ZERO = ( byte ) 0; + + private final ByteLongAccessType type; + + public ConvertedAccess( final ByteLongAccessType type ) + { + this.type = type; + } + + @Override + public boolean getValue( final int index ) + { + return type.get() > 0; + } + + @Override + public void setValue( final int index, final boolean value ) + { + type.set( value ? ONE : ZERO ); + } + + } + +} diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexDoubleLongAccessTypeComplexDoubleTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexDoubleLongAccessTypeComplexDoubleTypeConverter.java index 4535fb8..a049561 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexDoubleLongAccessTypeComplexDoubleTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexDoubleLongAccessTypeComplexDoubleTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexFloatLongAccessTypeComplexFloatTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexFloatLongAccessTypeComplexFloatTypeConverter.java index 8086132..ef9bb30 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexFloatLongAccessTypeComplexFloatTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/ComplexFloatLongAccessTypeComplexFloatTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/DoubleLongAccessTypeDoubleTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/DoubleLongAccessTypeDoubleTypeConverter.java index 82796ba..0e561c1 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/DoubleLongAccessTypeDoubleTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/DoubleLongAccessTypeDoubleTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/FloatLongAccessTypeFloatTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/FloatLongAccessTypeFloatTypeConverter.java index 9d06e12..922350b 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/FloatLongAccessTypeFloatTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/FloatLongAccessTypeFloatTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/IntLongAccessTypeIntTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/IntLongAccessTypeIntTypeConverter.java index 90469bc..8d572d2 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/IntLongAccessTypeIntTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/IntLongAccessTypeIntTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/LongLongAccessTypeLongTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/LongLongAccessTypeLongTypeConverter.java index 17ae6c2..27dd391 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/LongLongAccessTypeLongTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/LongLongAccessTypeLongTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/ShortLongAccessTypeShortTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/ShortLongAccessTypeShortTypeConverter.java index 5ea77dd..b44040d 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/ShortLongAccessTypeShortTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/ShortLongAccessTypeShortTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedByteLongAccessTypeUnsignedByteTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedByteLongAccessTypeUnsignedByteTypeConverter.java index cb1b754..f906a43 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedByteLongAccessTypeUnsignedByteTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedByteLongAccessTypeUnsignedByteTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedIntLongAccessTypeUnsignedIntTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedIntLongAccessTypeUnsignedIntTypeConverter.java index f8111f0..3d40529 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedIntLongAccessTypeUnsignedIntTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedIntLongAccessTypeUnsignedIntTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedLongLongAccessTypeUnsignedLongTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedLongLongAccessTypeUnsignedLongTypeConverter.java index 9662435..3b891b4 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedLongLongAccessTypeUnsignedLongTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedLongLongAccessTypeUnsignedLongTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedShortLongAccessTypeUnsignedShortTypeConverter.java b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedShortLongAccessTypeUnsignedShortTypeConverter.java index e500fdb..5ea078f 100644 --- a/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedShortLongAccessTypeUnsignedShortTypeConverter.java +++ b/src/main/java/net/imglib2/converter/readwrite/longaccess/UnsignedShortLongAccessTypeUnsignedShortTypeConverter.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/AbstractNativeLongAccessImg.java b/src/main/java/net/imglib2/img/AbstractNativeLongAccessImg.java index 29f8c31..7c1d9d0 100644 --- a/src/main/java/net/imglib2/img/AbstractNativeLongAccessImg.java +++ b/src/main/java/net/imglib2/img/AbstractNativeLongAccessImg.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/NativeLongAccessImg.java b/src/main/java/net/imglib2/img/NativeLongAccessImg.java index 6e77fd1..a05b6ed 100644 --- a/src/main/java/net/imglib2/img/NativeLongAccessImg.java +++ b/src/main/java/net/imglib2/img/NativeLongAccessImg.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/NativeLongAccessImgFactory.java b/src/main/java/net/imglib2/img/NativeLongAccessImgFactory.java index ac1e045..d66df58 100644 --- a/src/main/java/net/imglib2/img/NativeLongAccessImgFactory.java +++ b/src/main/java/net/imglib2/img/NativeLongAccessImgFactory.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -29,6 +29,7 @@ package net.imglib2.img; +import net.imglib2.img.basictypelongaccess.BooleanLongAccess; import net.imglib2.img.basictypelongaccess.ByteLongAccess; import net.imglib2.img.basictypelongaccess.CharLongAccess; import net.imglib2.img.basictypelongaccess.DoubleLongAccess; @@ -68,6 +69,8 @@ public NativeLongAccessImgFactory( final T t ) } /* basic type containers */ + public abstract NativeLongAccessImg< T, ? extends BooleanLongAccess> createNativeBooleanInstance( long[] dimensions, Fraction entitiesPerPixel ); + public abstract NativeLongAccessImg< T, ? extends ByteLongAccess > createByteInstance( long[] dimensions, Fraction entitiesPerPixel ); public abstract NativeLongAccessImg< T, ? extends CharLongAccess > createCharInstance( long[] dimensions, Fraction entitiesPerPixel ); diff --git a/src/main/java/net/imglib2/img/basictypeaccess/Accesses.java b/src/main/java/net/imglib2/img/basictypeaccess/Accesses.java index a36227a..ea5cd52 100644 --- a/src/main/java/net/imglib2/img/basictypeaccess/Accesses.java +++ b/src/main/java/net/imglib2/img/basictypeaccess/Accesses.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/BooleanLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/BooleanLongAccess.java new file mode 100644 index 0000000..c5efc68 --- /dev/null +++ b/src/main/java/net/imglib2/img/basictypelongaccess/BooleanLongAccess.java @@ -0,0 +1,45 @@ +/* + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imglib2.img.basictypelongaccess; + +import net.imglib2.img.basictypeaccess.BooleanAccess; + +/** + * A {@link BooleanAccess} that can also query indices representable by a + * {@code long} + * + * @author Gabriel Selzer + */ +public interface BooleanLongAccess extends BooleanAccess +{ + public boolean getValue( final long index ); + + public void setValue( final long index, final boolean value ); +} diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/ByteLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/ByteLongAccess.java index 445ea68..0b7b476 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/ByteLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/ByteLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,7 +32,8 @@ import net.imglib2.img.basictypeaccess.ByteAccess; /** - * TODO + * A {@link ByteAccess} that can also query indices representable by a + * {@code long} * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/CharLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/CharLongAccess.java index c5f777f..83e2008 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/CharLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/CharLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,7 +32,8 @@ import net.imglib2.img.basictypeaccess.CharAccess; /** - * TODO + * A {@link CharAccess} that can also query indices representable by a + * {@code long} * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/DoubleLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/DoubleLongAccess.java index 51ec954..f762497 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/DoubleLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/DoubleLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,7 +32,8 @@ import net.imglib2.img.basictypeaccess.DoubleAccess; /** - * TODO + * A {@link DoubleAccess} that can also query indices representable by a + * {@code long} * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/FloatLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/FloatLongAccess.java index 8fecc49..7bc62b7 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/FloatLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/FloatLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,7 +32,8 @@ import net.imglib2.img.basictypeaccess.FloatAccess; /** - * TODO + * A {@link FloatAccess} that can also query indices representable by a + * {@code long} * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/IntLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/IntLongAccess.java index 162a759..1a23009 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/IntLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/IntLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,7 +32,8 @@ import net.imglib2.img.basictypeaccess.IntAccess; /** - * TODO + * A {@link IntAccess} that can also query indices representable by a + * {@code long} * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/LongLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/LongLongAccess.java index bf2caed..7701665 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/LongLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/LongLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,7 +32,8 @@ import net.imglib2.img.basictypeaccess.LongAccess; /** - * TODO + * A {@link LongAccess} that can also query indices representable by a + * {@code long} * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/ShortLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/ShortLongAccess.java index 5ed2f91..393b270 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/ShortLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/ShortLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,7 +32,8 @@ import net.imglib2.img.basictypeaccess.ShortAccess; /** - * TODO + * A {@link ShortAccess} that can also query indices representable by a + * {@code long} * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/AbstractStridedUnsafeLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/AbstractStridedUnsafeLongAccess.java index c6af900..8c2d0ff 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/AbstractStridedUnsafeLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/AbstractStridedUnsafeLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/BooleanUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/BooleanUnsafe.java new file mode 100644 index 0000000..6564b7b --- /dev/null +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/BooleanUnsafe.java @@ -0,0 +1,139 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypelongaccess.unsafe; + +import net.imglib2.img.basictypeaccess.volatiles.VolatileBooleanAccess; +import net.imglib2.img.basictypelongaccess.BooleanLongAccess; + +/** + * A {@link BooleanLongAccess} that accesses memory, starting from + * {@code address}. + * + * @author Gabriel Selzer + */ +public class BooleanUnsafe + implements BooleanLongAccess, VolatileBooleanAccess +{ + private static final boolean DEFAULT_IS_VALID = true; + private static final byte ZERO = (byte) 0; + private static final byte ONE = (byte) 1; + + private final ByteUnsafe wrapped; + + public BooleanUnsafe( final long address ) + { + this( address, null ); + } + + public BooleanUnsafe( final long address, final boolean isValid ) + { + this( address, null, isValid ); + } + + public BooleanUnsafe( final long address, final Object ownerReference ) + { + this( address, ownerReference, DEFAULT_IS_VALID ); + } + + /** + * Standard {@link BooleanUnsafe} constructor. + * + * @param address + * the address in memory to index from + * @param ownerReference + * a reference to another {@link Object} that can hold control + * over the memory starting at {@code address}. Can be used to + * ensure that the backing memory is not + * garbage-collected. + * @param isValid + * - denotes the validity of this {@link BooleanUnsafe} + */ + public BooleanUnsafe( final long address, final Object ownerReference, final boolean isValid ) + { + super(); + this.wrapped = new ByteUnsafe(address, ownerReference, isValid); + } + + @Override + public boolean getValue( final int index ) + { + return getValue( ( long ) index ); + } + + @Override + public void setValue( final int index, final boolean value ) + { + setValue( ( long ) index, value ); + } + + /** + * Returns the boolean value at {@code index}. + * + * @param index + * the offset (in bytes) from {@code address}. + * @return the value at {@code index} + */ + @Override + public boolean getValue( final long index ) + { + return wrapped.getValue(index) > 0; + } + + /** + * Sets the value at {@code index}. + * + * @param index + * the offset (in bytes) from {@code address} + * @param value + * the boolean value to be set at {@code index} + */ + @Override + public void setValue( final long index, final boolean value ) + { + wrapped.setValue(index, value ? ONE : ZERO); + } + + public long getAddres() + { + return wrapped.getAddres(); + } + + @Override + public boolean isValid() + { + return wrapped.isValid(); + } + + @Override + public void finalize() throws Throwable + { + wrapped.finalize(); + } + +} diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ByteUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ByteUnsafe.java index 44fa976..e690121 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ByteUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ByteUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/CharUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/CharUnsafe.java index e49e4b2..2a14c2e 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/CharUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/CharUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/DoubleUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/DoubleUnsafe.java index 864f045..f1c0d98 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/DoubleUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/DoubleUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/FloatUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/FloatUnsafe.java index 9113bde..9550c07 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/FloatUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/FloatUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/IntUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/IntUnsafe.java index d6f5938..b05fcc2 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/IntUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/IntUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/LongUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/LongUnsafe.java index 57019f7..f471f11 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/LongUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/LongUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/NativeBooleanUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/NativeBooleanUnsafe.java new file mode 100644 index 0000000..f50c455 --- /dev/null +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/NativeBooleanUnsafe.java @@ -0,0 +1,139 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypelongaccess.unsafe; + +import net.imglib2.img.basictypeaccess.volatiles.VolatileBooleanAccess; +import net.imglib2.img.basictypelongaccess.BooleanLongAccess; + +/** + * A {@link BooleanLongAccess} that accesses memory, starting from + * {@code address}. + * + * @author Gabriel Selzer + */ +public class NativeBooleanUnsafe + implements BooleanLongAccess, VolatileBooleanAccess +{ + private static final boolean DEFAULT_IS_VALID = true; + private static final byte ZERO = (byte) 0; + private static final byte ONE = (byte) 1; + + private final ByteUnsafe wrapped; + + public NativeBooleanUnsafe( final long address ) + { + this( address, null ); + } + + public NativeBooleanUnsafe( final long address, final boolean isValid ) + { + this( address, null, isValid ); + } + + public NativeBooleanUnsafe( final long address, final Object ownerReference ) + { + this( address, ownerReference, DEFAULT_IS_VALID ); + } + + /** + * Standard {@link NativeBooleanUnsafe} constructor. + * + * @param address + * the address in memory to index from + * @param ownerReference + * a reference to another {@link Object} that can hold control + * over the memory starting at {@code address}. Can be used to + * ensure that the backing memory is not + * garbage-collected. + * @param isValid + * - denotes the validity of this {@link NativeBooleanUnsafe} + */ + public NativeBooleanUnsafe( final long address, final Object ownerReference, final boolean isValid ) + { + super(); + this.wrapped = new ByteUnsafe(address, ownerReference, isValid); + } + + @Override + public boolean getValue( final int index ) + { + return getValue( ( long ) index ); + } + + @Override + public void setValue( final int index, final boolean value ) + { + setValue( ( long ) index, value ); + } + + /** + * Returns the boolean value at {@code index}. + * + * @param index + * the offset (in bytes) from {@code address}. + * @return the value at {@code index} + */ + @Override + public boolean getValue( final long index ) + { + return wrapped.getValue(index) > 0; + } + + /** + * Sets the value at {@code index}. + * + * @param index + * the offset (in bytes) from {@code address} + * @param value + * the boolean value to be set at {@code index} + */ + @Override + public void setValue( final long index, final boolean value ) + { + wrapped.setValue(index, value ? ONE : ZERO); + } + + public long getAddres() + { + return wrapped.getAddres(); + } + + @Override + public boolean isValid() + { + return wrapped.isValid(); + } + + @Override + public void finalize() throws Throwable + { + wrapped.finalize(); + } + +} diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ShortUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ShortUnsafe.java index fece6ac..5d0d148 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ShortUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/ShortUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccess.java index 29036b7..bd624be 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccessFactory.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccessFactory.java index f8e1f91..0597d10 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccessFactory.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeAccessFactory.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeUtil.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeUtil.java index 5aa7161..eee0167 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeUtil.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/UnsafeUtil.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/AbstractOwningUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/AbstractOwningUnsafe.java index 172a1b5..fc73b04 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/AbstractOwningUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/AbstractOwningUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningBooleanUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningBooleanUnsafe.java new file mode 100644 index 0000000..08497bd --- /dev/null +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningBooleanUnsafe.java @@ -0,0 +1,122 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypelongaccess.unsafe.owning; + +import net.imglib2.img.basictypeaccess.volatiles.VolatileBooleanAccess; +import net.imglib2.img.basictypelongaccess.BooleanLongAccess; +import net.imglib2.img.basictypelongaccess.unsafe.BooleanUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeAccess; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; +import net.imglib2.type.PrimitiveType; + +/** + * A convenience wrapper for {@link BooleanUnsafe} that uses itself as the + * owner of the memory accessed. + * + * @author Gabriel Selzer + */ +public class OwningBooleanUnsafe extends AbstractOwningUnsafe implements + BooleanLongAccess, UnsafeAccess, + VolatileBooleanAccess +{ + private static final boolean DEFAULT_IS_VALID = true; + + private final BooleanUnsafe unsafe; + + private final long numEntities; + + public OwningBooleanUnsafe( final long numEntities ) + { + this( numEntities, DEFAULT_IS_VALID ); + } + + /** + * The default {@link OwningBooleanUnsafe} constructor + * + * @param numEntities + * the size (in number of indices) of the backing memory. + * @param isValid + * the validity of this {@link OwningBooleanUnsafe} + */ + public OwningBooleanUnsafe( final long numEntities, final boolean isValid ) + { + super( UnsafeUtil.create( numEntities ) ); + this.unsafe = new BooleanUnsafe( owner.getAddress(), this, isValid ); + this.numEntities = numEntities; + } + + @Override + public boolean getValue( final int index ) + { + return unsafe.getValue( index ); + } + + @Override + public void setValue( final int index, final boolean value ) + { + unsafe.setValue( index, value ); + } + + @Override + public boolean getValue( final long index ) + { + return unsafe.getValue( index ); + } + + @Override + public void setValue( final long index, final boolean value ) + { + unsafe.setValue( index, value ); + } + + @Override + public OwningBooleanUnsafe createAccess( final long numEntities ) + { + return new OwningBooleanUnsafe( numEntities, isValid() ); + } + + @Override + public PrimitiveType getType() + { + return PrimitiveType.BYTE; + } + + @Override + public long getSize() + { + return this.numEntities; + } + + @Override + public boolean isValid() + { + return unsafe.isValid(); + } + +} diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningByteUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningByteUnsafe.java index 7a439e6..37dde0d 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningByteUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningByteUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningCharUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningCharUnsafe.java index 83e8108..e424488 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningCharUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningCharUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningDoubleUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningDoubleUnsafe.java index 15a0fd2..0a2fca0 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningDoubleUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningDoubleUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningFloatUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningFloatUnsafe.java index 01a3c7e..7d1020a 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningFloatUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningFloatUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningIntUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningIntUnsafe.java index 7910df4..1ec7966 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningIntUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningIntUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningLongUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningLongUnsafe.java index be179b6..107e814 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningLongUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningLongUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningNativeBooleanUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningNativeBooleanUnsafe.java new file mode 100644 index 0000000..8d117b6 --- /dev/null +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningNativeBooleanUnsafe.java @@ -0,0 +1,122 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypelongaccess.unsafe.owning; + +import net.imglib2.img.basictypeaccess.volatiles.VolatileBooleanAccess; +import net.imglib2.img.basictypelongaccess.BooleanLongAccess; +import net.imglib2.img.basictypelongaccess.unsafe.NativeBooleanUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeAccess; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; +import net.imglib2.type.PrimitiveType; + +/** + * A convenience wrapper for {@link NativeBooleanUnsafe} that uses itself as the + * owner of the memory accessed. + * + * @author Gabriel Selzer + */ +public class OwningNativeBooleanUnsafe extends AbstractOwningUnsafe implements + BooleanLongAccess, UnsafeAccess, + VolatileBooleanAccess +{ + private static final boolean DEFAULT_IS_VALID = true; + + private final NativeBooleanUnsafe unsafe; + + private final long numEntities; + + public OwningNativeBooleanUnsafe( final long numEntities ) + { + this( numEntities, DEFAULT_IS_VALID ); + } + + /** + * The default {@link OwningNativeBooleanUnsafe} constructor + * + * @param numEntities + * the size (in number of indices) of the backing memory. + * @param isValid + * the validity of this {@link OwningNativeBooleanUnsafe} + */ + public OwningNativeBooleanUnsafe( final long numEntities, final boolean isValid ) + { + super( UnsafeUtil.create( numEntities ) ); + this.unsafe = new NativeBooleanUnsafe( owner.getAddress(), this, isValid ); + this.numEntities = numEntities; + } + + @Override + public boolean getValue( final int index ) + { + return unsafe.getValue( index ); + } + + @Override + public void setValue( final int index, final boolean value ) + { + unsafe.setValue( index, value ); + } + + @Override + public boolean getValue( final long index ) + { + return unsafe.getValue( index ); + } + + @Override + public void setValue( final long index, final boolean value ) + { + unsafe.setValue( index, value ); + } + + @Override + public OwningNativeBooleanUnsafe createAccess( final long numEntities ) + { + return new OwningNativeBooleanUnsafe( numEntities, isValid() ); + } + + @Override + public PrimitiveType getType() + { + return PrimitiveType.BYTE; + } + + @Override + public long getSize() + { + return this.numEntities; + } + + @Override + public boolean isValid() + { + return unsafe.isValid(); + } + +} diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningShortUnsafe.java b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningShortUnsafe.java index 53bdcfc..394cab7 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningShortUnsafe.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/unsafe/owning/OwningShortUnsafe.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedBooleanLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedBooleanLongAccess.java new file mode 100644 index 0000000..8b5dd46 --- /dev/null +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedBooleanLongAccess.java @@ -0,0 +1,74 @@ +/* + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imglib2.img.basictypelongaccess.wrapped; + +import net.imglib2.img.basictypeaccess.BooleanAccess; +import net.imglib2.img.basictypelongaccess.BooleanLongAccess; + +/** + * A {@link BooleanLongAccess} backed by a {@link BooleanAccess}. + * + * @author Curtis Rueden + */ +public class WrappedBooleanLongAccess< A extends BooleanAccess > implements BooleanLongAccess +{ + + private final A access; + + public WrappedBooleanLongAccess( final A access ) + { + super(); + this.access = access; + } + + @Override + public boolean getValue( final long index ) + { + return getValue( ( int ) index ); + } + + @Override + public void setValue( final long index, final boolean value ) + { + setValue( ( int ) index, value ); + } + + @Override + public boolean getValue( final int index ) + { + return access.getValue( index ); + } + + @Override + public void setValue( final int index, final boolean value ) + { + access.setValue( index, value ); + } +} diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedByteLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedByteLongAccess.java index 2e2445c..01832d3 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedByteLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedByteLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import net.imglib2.img.basictypelongaccess.ByteLongAccess; /** - * TODO + * A {@link ByteLongAccess} backed by a {@link ByteAccess}. * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedCharLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedCharLongAccess.java index 20f6909..c2ef668 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedCharLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedCharLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import net.imglib2.img.basictypelongaccess.CharLongAccess; /** - * TODO + * A {@link CharLongAccess} backed by a {@link CharAccess}. * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedDoubleLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedDoubleLongAccess.java index 9687ce3..45d143d 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedDoubleLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedDoubleLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import net.imglib2.img.basictypelongaccess.DoubleLongAccess; /** - * TODO + * A {@link DoubleLongAccess} backed by a {@link DoubleAccess}. * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedFloatLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedFloatLongAccess.java index a1e0f86..a399ca6 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedFloatLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedFloatLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import net.imglib2.img.basictypelongaccess.FloatLongAccess; /** - * TODO + * A {@link FloatLongAccess} backed by a {@link FloatAccess}. * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedIntLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedIntLongAccess.java index a200a62..d2fc7cf 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedIntLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedIntLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import net.imglib2.img.basictypelongaccess.IntLongAccess; /** - * TODO + * An {@link IntLongAccess} backed by an {@link IntAccess}. * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedLongLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedLongLongAccess.java index d1df048..b65a6d7 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedLongLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedLongLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import net.imglib2.img.basictypelongaccess.LongLongAccess; /** - * TODO + * A {@link LongLongAccess} backed by a {@link LongAccess}. * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedShortLongAccess.java b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedShortLongAccess.java index dbd7e09..93772fe 100644 --- a/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedShortLongAccess.java +++ b/src/main/java/net/imglib2/img/basictypelongaccess/wrapped/WrappedShortLongAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ import net.imglib2.img.basictypelongaccess.ShortLongAccess; /** - * TODO + * A {@link ShortLongAccess} backed by a {@link ShortAccess}. * * @author Stephan Preibisch * @author Stephan Saalfeld diff --git a/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeCursor.java b/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeCursor.java index d792e17..4ac39f2 100644 --- a/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeCursor.java +++ b/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeCursor.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeLocalizingCursor.java b/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeLocalizingCursor.java index a386f10..ccea8c8 100644 --- a/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeLocalizingCursor.java +++ b/src/main/java/net/imglib2/img/unsafe/AbstractUnsafeLocalizingCursor.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeCursor.java b/src/main/java/net/imglib2/img/unsafe/UnsafeCursor.java index 31f01cb..110f459 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeCursor.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeCursor.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeImg.java b/src/main/java/net/imglib2/img/unsafe/UnsafeImg.java index 365237c..861e25a 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeImg.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeImg.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeImgFactory.java b/src/main/java/net/imglib2/img/unsafe/UnsafeImgFactory.java index 476394a..ddf95b5 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeImgFactory.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeImgFactory.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -42,6 +42,7 @@ import net.imglib2.img.basictypelongaccess.unsafe.owning.OwningFloatUnsafe; import net.imglib2.img.basictypelongaccess.unsafe.owning.OwningIntUnsafe; import net.imglib2.img.basictypelongaccess.unsafe.owning.OwningLongUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.owning.OwningBooleanUnsafe; import net.imglib2.img.basictypelongaccess.unsafe.owning.OwningShortUnsafe; import net.imglib2.type.NativeLongAccessType; import net.imglib2.type.NativeLongAccessTypeFactory; @@ -81,6 +82,14 @@ public static long numEntities( final long[] dimensions, final Fraction entities return numEntities; } + @Override + public UnsafeImg< T, OwningBooleanUnsafe > createNativeBooleanInstance( final long[] dimensions, final Fraction entitiesPerPixel ) + { + final long numEntities = numEntities( dimensions, entitiesPerPixel ); + + return new UnsafeImg<>( new OwningBooleanUnsafe( numEntities ), dimensions, entitiesPerPixel ); + } + @Override public UnsafeImg< T, OwningByteUnsafe > createByteInstance( final long[] dimensions, final Fraction entitiesPerPixel ) { diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeImgs.java b/src/main/java/net/imglib2/img/unsafe/UnsafeImgs.java index e6b4a9b..c78902f 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeImgs.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeImgs.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingCursor.java b/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingCursor.java index 008428a..2efa72d 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingCursor.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingCursor.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingSubIntervalCursor.java b/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingSubIntervalCursor.java index d831525..c43784b 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingSubIntervalCursor.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeLocalizingSubIntervalCursor.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeRandomAccess.java b/src/main/java/net/imglib2/img/unsafe/UnsafeRandomAccess.java index 9ef8993..3af69a4 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeRandomAccess.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeRandomAccess.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/img/unsafe/UnsafeSubIntervalCursor.java b/src/main/java/net/imglib2/img/unsafe/UnsafeSubIntervalCursor.java index 395c582..e048633 100644 --- a/src/main/java/net/imglib2/img/unsafe/UnsafeSubIntervalCursor.java +++ b/src/main/java/net/imglib2/img/unsafe/UnsafeSubIntervalCursor.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/AbstractNativeLongAccessType.java b/src/main/java/net/imglib2/type/AbstractNativeLongAccessType.java index d568f1f..6c20b5f 100644 --- a/src/main/java/net/imglib2/type/AbstractNativeLongAccessType.java +++ b/src/main/java/net/imglib2/type/AbstractNativeLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/NativeLongAccessType.java b/src/main/java/net/imglib2/type/NativeLongAccessType.java index 92d01b5..db28214 100644 --- a/src/main/java/net/imglib2/type/NativeLongAccessType.java +++ b/src/main/java/net/imglib2/type/NativeLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/NativeLongAccessTypeFactory.java b/src/main/java/net/imglib2/type/NativeLongAccessTypeFactory.java index a0899ba..80bacd1 100644 --- a/src/main/java/net/imglib2/type/NativeLongAccessTypeFactory.java +++ b/src/main/java/net/imglib2/type/NativeLongAccessTypeFactory.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -31,6 +31,7 @@ import java.util.function.Function; import net.imglib2.img.NativeLongAccessImg; +import net.imglib2.img.basictypelongaccess.BooleanLongAccess; import net.imglib2.img.basictypelongaccess.ByteLongAccess; import net.imglib2.img.basictypelongaccess.CharLongAccess; import net.imglib2.img.basictypelongaccess.DoubleLongAccess; @@ -107,6 +108,11 @@ public T createLinkedType( final NativeLongAccessImg< T, ? extends A > img ) return createLinkedType.apply( img ); } + public static < T extends NativeLongAccessType< T >, A extends BooleanLongAccess > NativeLongAccessTypeFactory< T, A > BOOLEAN( final Function< NativeLongAccessImg< T, ? extends A >, T > createLinkedType ) + { + return new NativeLongAccessTypeFactory<>( PrimitiveType.BOOLEAN, createLinkedType ); + } + public static < T extends NativeLongAccessType< T >, A extends ByteLongAccess > NativeLongAccessTypeFactory< T, A > BYTE( final Function< NativeLongAccessImg< T, ? extends A >, T > createLinkedType ) { return new NativeLongAccessTypeFactory<>( PrimitiveType.BYTE, createLinkedType ); diff --git a/src/main/java/net/imglib2/type/numeric/ARGBLongAccessType.java b/src/main/java/net/imglib2/type/numeric/ARGBLongAccessType.java index 2e95a9f..8e3333d 100644 --- a/src/main/java/net/imglib2/type/numeric/ARGBLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/ARGBLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/complex/ComplexDoubleLongAccessType.java b/src/main/java/net/imglib2/type/numeric/complex/ComplexDoubleLongAccessType.java index 8b7ba10..a2410f1 100644 --- a/src/main/java/net/imglib2/type/numeric/complex/ComplexDoubleLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/complex/ComplexDoubleLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/complex/ComplexFloatLongAccessType.java b/src/main/java/net/imglib2/type/numeric/complex/ComplexFloatLongAccessType.java index 74577e0..7b3dff8 100644 --- a/src/main/java/net/imglib2/type/numeric/complex/ComplexFloatLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/complex/ComplexFloatLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/ByteLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/ByteLongAccessType.java index 407d336..690396a 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/ByteLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/ByteLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/GenericByteLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/GenericByteLongAccessType.java index 1d67b57..079fdae 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/GenericByteLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/GenericByteLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/GenericIntLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/GenericIntLongAccessType.java index 0069c5c..3e89e47 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/GenericIntLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/GenericIntLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/GenericLongLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/GenericLongLongAccessType.java index e917aeb..6b74977 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/GenericLongLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/GenericLongLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/GenericShortLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/GenericShortLongAccessType.java index 5f34016..85ca5c1 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/GenericShortLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/GenericShortLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/IntLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/IntLongAccessType.java index 925ef42..be632f3 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/IntLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/IntLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/LongLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/LongLongAccessType.java index fb303df..abb6479 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/LongLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/LongLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/ShortLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/ShortLongAccessType.java index 2610cc6..df5fe19 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/ShortLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/ShortLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/UnsignedByteLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/UnsignedByteLongAccessType.java index d496bf7..7f250ae 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/UnsignedByteLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/UnsignedByteLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/UnsignedIntLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/UnsignedIntLongAccessType.java index fe8a939..c507c66 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/UnsignedIntLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/UnsignedIntLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/UnsignedLongLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/UnsignedLongLongAccessType.java index 105fe3d..3440caf 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/UnsignedLongLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/UnsignedLongLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/integer/UnsignedShortLongAccessType.java b/src/main/java/net/imglib2/type/numeric/integer/UnsignedShortLongAccessType.java index 36dd3a7..3b63f5c 100644 --- a/src/main/java/net/imglib2/type/numeric/integer/UnsignedShortLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/integer/UnsignedShortLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/real/DoubleLongAccessType.java b/src/main/java/net/imglib2/type/numeric/real/DoubleLongAccessType.java index 3add611..8a72c74 100644 --- a/src/main/java/net/imglib2/type/numeric/real/DoubleLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/real/DoubleLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/main/java/net/imglib2/type/numeric/real/FloatLongAccessType.java b/src/main/java/net/imglib2/type/numeric/real/FloatLongAccessType.java index 99c013f..81f1df0 100644 --- a/src/main/java/net/imglib2/type/numeric/real/FloatLongAccessType.java +++ b/src/main/java/net/imglib2/type/numeric/real/FloatLongAccessType.java @@ -2,7 +2,7 @@ * #%L * ImgLib2 data structures using Unsafe. * %% - * Copyright (C) 2017 - 2021 Howard Hughes Medical Institute. + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. * %% * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/src/test/java/net/imglib2/converter/readwrite/longaccess/LongAccessTypeToTypeConverterTest.java b/src/test/java/net/imglib2/converter/readwrite/longaccess/LongAccessTypeToTypeConverterTest.java new file mode 100644 index 0000000..e172e96 --- /dev/null +++ b/src/test/java/net/imglib2/converter/readwrite/longaccess/LongAccessTypeToTypeConverterTest.java @@ -0,0 +1,239 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.converter.readwrite.longaccess; + +import net.imglib2.Sampler; +import net.imglib2.converter.readwrite.SamplerConverter; +import net.imglib2.type.logic.NativeBoolType; +import net.imglib2.type.numeric.complex.ComplexDoubleLongAccessType; +import net.imglib2.type.numeric.complex.ComplexDoubleType; +import net.imglib2.type.numeric.complex.ComplexFloatLongAccessType; +import net.imglib2.type.numeric.complex.ComplexFloatType; +import net.imglib2.type.numeric.integer.ByteLongAccessType; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.integer.ShortLongAccessType; +import net.imglib2.type.numeric.integer.IntLongAccessType; +import net.imglib2.type.numeric.integer.LongLongAccessType; +import net.imglib2.type.numeric.integer.ByteType; +import net.imglib2.type.numeric.integer.ShortType; +import net.imglib2.type.numeric.integer.UnsignedByteLongAccessType; +import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.type.numeric.integer.UnsignedIntLongAccessType; +import net.imglib2.type.numeric.integer.UnsignedIntType; +import net.imglib2.type.numeric.integer.UnsignedLongLongAccessType; +import net.imglib2.type.numeric.integer.UnsignedLongType; +import net.imglib2.type.numeric.integer.UnsignedShortLongAccessType; +import net.imglib2.type.numeric.integer.UnsignedShortType; +import net.imglib2.type.numeric.real.FloatLongAccessType; +import net.imglib2.type.numeric.real.DoubleLongAccessType; +import net.imglib2.type.numeric.real.FloatType; +import net.imglib2.type.numeric.real.DoubleType; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Tests the {@link SamplerConverter}s of this project + * + * @author Gabriel Selzer + */ +public class LongAccessTypeToTypeConverterTest +{ + + private static < T, U > U convert( T access, SamplerConverter< T, U > converter ) + { + Sampler< T > sampler = new Sampler< T >() + { + + @Override + public T get() + { + return access; + } + + @Override + public Sampler< T > copy() + { + return null; + } + }; + return converter.convert( sampler ); + } + + @Test + public void testNativeBoolean() + { + ByteLongAccessType access = new ByteLongAccessType( ( byte ) 4 ); + NativeBoolType converted = convert( access, new ByteLongAccessTypeNativeBoolTypeConverter() ); + boolean value = false; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( 0, access.get() ); + } + + @Test + public void testByte() + { + ByteLongAccessType access = new ByteLongAccessType( ( byte ) 4 ); + ByteType converted = convert( access, new ByteLongAccessTypeByteTypeConverter() ); + byte value = 5; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + + @Test + public void testShort() + { + ShortLongAccessType access = new ShortLongAccessType( ( short ) 4 ); + ShortType converted = convert( access, new ShortLongAccessTypeShortTypeConverter() ); + short value = 5; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + + @Test + public void testInteger() + { + IntLongAccessType access = new IntLongAccessType( 4 ); + IntType converted = convert( access, new IntLongAccessTypeIntTypeConverter() ); + int value = 5; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + + @Test + public void testLong() + { + LongLongAccessType access = new LongLongAccessType( 4L ); + LongType converted = convert( access, new LongLongAccessTypeLongTypeConverter() ); + long value = 5L; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + + @Test + public void testFloat() + { + FloatLongAccessType access = new FloatLongAccessType( 4f ); + FloatType converted = convert( access, new FloatLongAccessTypeFloatTypeConverter() ); + float value = 5f; + converted.set( value ); + assertEquals( value, converted.get(), 1e-6 ); + assertEquals( value, access.get(), 1e-6 ); + } + + @Test + public void testDouble() + { + DoubleLongAccessType access = new DoubleLongAccessType( 4d ); + DoubleType converted = convert( access, new DoubleLongAccessTypeDoubleTypeConverter() ); + double value = 5d; + converted.set( value ); + assertEquals( value, converted.get(), 1e-6 ); + assertEquals( value, access.get(), 1e-6 ); + } + + @Test + public void testComplexFloat() + { + ComplexFloatLongAccessType access = new ComplexFloatLongAccessType( 4f, 4f ); + ComplexFloatType converted = convert( access, new ComplexFloatLongAccessTypeComplexFloatTypeConverter() ); + float real = 5f; + float imag = 5f; + converted.set( real, imag ); + assertEquals( real, converted.getRealDouble(), 1e-6 ); + assertEquals( real, access.getRealDouble(), 1e-6 ); + assertEquals( imag, converted.getImaginaryDouble(), 1e-6 ); + assertEquals( imag, access.getImaginaryDouble(), 1e-6 ); + } + + @Test + public void testComplexDouble() + { + ComplexDoubleLongAccessType access = new ComplexDoubleLongAccessType( 4d, 4d ); + ComplexDoubleType converted = convert( access, new ComplexDoubleLongAccessTypeComplexDoubleTypeConverter() ); + double real = 5d; + double imag = 5d; + converted.set( real, imag ); + assertEquals( real, converted.getRealDouble(), 1e-6 ); + assertEquals( real, access.getRealDouble(), 1e-6 ); + assertEquals( imag, converted.getImaginaryDouble(), 1e-6 ); + assertEquals( imag, access.getImaginaryDouble(), 1e-6 ); + } + + @Test + public void testUnsignedByte() + { + UnsignedByteLongAccessType access = new UnsignedByteLongAccessType( 4 ); + UnsignedByteType converted = convert( access, new UnsignedByteLongAccessTypeUnsignedByteTypeConverter() ); + byte value = 5; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + + @Test + public void testUnsignedShort() + { + UnsignedShortLongAccessType access = new UnsignedShortLongAccessType( 4 ); + UnsignedShortType converted = convert( access, new UnsignedShortLongAccessTypeUnsignedShortTypeConverter() ); + short value = 5; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + + @Test + public void testUnsignedInteger() + { + UnsignedIntLongAccessType access = new UnsignedIntLongAccessType( 4 ); + UnsignedIntType converted = convert( access, new UnsignedIntLongAccessTypeUnsignedIntTypeConverter() ); + int value = 5; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + + @Test + public void testUnsignedLong() + { + UnsignedLongLongAccessType access = new UnsignedLongLongAccessType( 4L ); + UnsignedLongType converted = convert( access, new UnsignedLongLongAccessTypeUnsignedLongTypeConverter() ); + long value = 5L; + converted.set( value ); + assertEquals( value, converted.get() ); + assertEquals( value, access.get() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/BooleanUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/BooleanUnsafeTest.java new file mode 100644 index 0000000..7b4c97f --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/BooleanUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.BooleanUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link BooleanUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class BooleanUnsafeTest +{ + + private BooleanUnsafe b; + + private long address; + + private final Boolean startingValue = false; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + b = new BooleanUnsafe( address ); + b.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( b.getAddres() ); + } + + @Test + public void testBooleanUnsafeGetValue() + { + assertEquals( startingValue, b.getValue( 0 ) ); + } + + @Test + public void testBooleanUnsafeSetValue() + { + boolean newValue = true; + b.setValue( 0, newValue ); + assertEquals( newValue, b.getValue( 0 ) ); + } + + @Test + public void testBooleanUnsafeGetAddress() + { + assertEquals( address, b.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/ByteUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/ByteUnsafeTest.java new file mode 100644 index 0000000..be90709 --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/ByteUnsafeTest.java @@ -0,0 +1,90 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import net.imglib2.img.basictypelongaccess.unsafe.ByteUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Tests basic {@link ByteUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class ByteUnsafeTest +{ + + private ByteUnsafe b; + + private long address; + + private final Byte startingValue = 5; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + b = new ByteUnsafe( address ); + b.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( b.getAddres() ); + } + + @Test + public void testByteUnsafeGetValue() + { + assertEquals( ( long ) startingValue, b.getValue( 0 ) ); + } + + @Test + public void testByteUnsafeSetValue() + { + byte newValue = 6; + b.setValue( 0, newValue ); + assertEquals( newValue, b.getValue( 0 ) ); + } + + @Test + public void testByteUnsafeGetAddress() + { + assertEquals( address, b.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/CharUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/CharUnsafeTest.java new file mode 100644 index 0000000..6e1999d --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/CharUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import net.imglib2.img.basictypelongaccess.unsafe.CharUnsafe; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link CharUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class CharUnsafeTest +{ + + private CharUnsafe c; + + private long address; + + private final Character startingValue = 'a'; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + c = new CharUnsafe( address ); + c.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( c.getAddres() ); + } + + @Test + public void testCharUnsafeGetValue() + { + assertEquals( ( long ) startingValue, c.getValue( 0 ) ); + } + + @Test + public void testCharUnsafeSetValue() + { + char newValue = 'b'; + c.setValue( 0, newValue ); + assertEquals( newValue, c.getValue( 0 ) ); + } + + @Test + public void testCharUnsafeGetAddress() + { + assertEquals( address, c.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/DoubleUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/DoubleUnsafeTest.java new file mode 100644 index 0000000..dd8b538 --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/DoubleUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.DoubleUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link DoubleUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class DoubleUnsafeTest +{ + + private DoubleUnsafe d; + + private long address; + + private final Double startingValue = 5d; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + d = new DoubleUnsafe( address ); + d.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( d.getAddres() ); + } + + @Test + public void testDoubleUnsafeGetValue() + { + assertEquals( startingValue, d.getValue( 0 ), 1e-6 ); + } + + @Test + public void testDoubleUnsafeSetValue() + { + double newValue = 6d; + d.setValue( 0, newValue ); + assertEquals( newValue, d.getValue( 0 ), 1e-6 ); + } + + @Test + public void testDoubleUnsafeGetAddress() + { + assertEquals( address, d.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/FloatUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/FloatUnsafeTest.java new file mode 100644 index 0000000..4478252 --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/FloatUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.FloatUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link FloatUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class FloatUnsafeTest +{ + + private FloatUnsafe f; + + private long address; + + private final Float startingValue = 5f; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + f = new FloatUnsafe( address ); + f.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( f.getAddres() ); + } + + @Test + public void testFloatUnsafeGetValue() + { + assertEquals( startingValue, f.getValue( 0 ), 1e-6 ); + } + + @Test + public void testFloatUnsafeSetValue() + { + float newValue = 6f; + f.setValue( 0, newValue ); + assertEquals( newValue, f.getValue( 0 ), 1e-6 ); + } + + @Test + public void testFloatUnsafeGetAddress() + { + assertEquals( address, f.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/IntUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/IntUnsafeTest.java new file mode 100644 index 0000000..a8d96a6 --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/IntUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.IntUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link IntUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class IntUnsafeTest +{ + + private IntUnsafe i; + + private long address; + + private final Integer startingValue = 5; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + i = new IntUnsafe( address ); + i.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( i.getAddres() ); + } + + @Test + public void testIntUnsafeGetValue() + { + assertEquals( ( long ) startingValue, i.getValue( 0 ) ); + } + + @Test + public void testIntUnsafeSetValue() + { + int newValue = 6; + i.setValue( 0, newValue ); + assertEquals( newValue, i.getValue( 0 ) ); + } + + @Test + public void testIntUnsafeGetAddress() + { + assertEquals( address, i.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/LongUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/LongUnsafeTest.java new file mode 100644 index 0000000..b2f626e --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/LongUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.LongUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link LongUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class LongUnsafeTest +{ + + private LongUnsafe l; + + private long address; + + private final Long startingValue = 5L; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + l = new LongUnsafe( address ); + l.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( l.getAddres() ); + } + + @Test + public void testLongUnsafeGetValue() + { + assertEquals( ( long ) startingValue, l.getValue( 0 ) ); + } + + @Test + public void testLongUnsafeSetValue() + { + long newValue = 6L; + l.setValue( 0, newValue ); + assertEquals( ( long ) newValue, l.getValue( 0 ) ); + } + + @Test + public void testLongUnsafeGetAddress() + { + assertEquals( address, l.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/NativeBooleanUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/NativeBooleanUnsafeTest.java new file mode 100644 index 0000000..14160b4 --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/NativeBooleanUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.NativeBooleanUnsafe; +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link NativeBooleanUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class NativeBooleanUnsafeTest +{ + + private NativeBooleanUnsafe b; + + private long address; + + private final Boolean startingValue = false; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + b = new NativeBooleanUnsafe( address ); + b.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( b.getAddres() ); + } + + @Test + public void testNativeBooleanUnsafeGetValue() + { + assertEquals( startingValue, b.getValue( 0 ) ); + } + + @Test + public void testNativeBooleanUnsafeSetValue() + { + boolean newValue = true; + b.setValue( 0, newValue ); + assertEquals( newValue, b.getValue( 0 ) ); + } + + @Test + public void testNativeBooleanUnsafeGetAddress() + { + assertEquals( address, b.getAddres() ); + } + +} diff --git a/src/test/java/net/imglib2/img/basictypeaccess/unsafe/ShortUnsafeTest.java b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/ShortUnsafeTest.java new file mode 100644 index 0000000..391d556 --- /dev/null +++ b/src/test/java/net/imglib2/img/basictypeaccess/unsafe/ShortUnsafeTest.java @@ -0,0 +1,91 @@ +/*- + * #%L + * ImgLib2 data structures using Unsafe. + * %% + * Copyright (C) 2017 - 2023 Howard Hughes Medical Institute. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imglib2.img.basictypeaccess.unsafe; + +import static org.junit.Assert.assertEquals; + +import net.imglib2.img.basictypelongaccess.unsafe.ShortUnsafe; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import net.imglib2.img.basictypelongaccess.unsafe.UnsafeUtil; + +/** + * Tests basic {@link ShortUnsafe} functionality + * + * @author Gabriel Selzer + */ +public class ShortUnsafeTest +{ + + private ShortUnsafe s; + + private long address; + + private final Short startingValue = 5; + + @Before + public void setup() + { + // Allocate heap memory for testing + address = UnsafeUtil.UNSAFE.allocateMemory( 8 ); + + s = new ShortUnsafe( address ); + s.setValue( 0, startingValue ); + } + + @After + public void tearDown() + { + // Free heap memory + UnsafeUtil.UNSAFE.freeMemory( s.getAddres() ); + } + + @Test + public void testShortUnsafeGetValue() + { + assertEquals( ( long ) startingValue, s.getValue( 0 ) ); + } + + @Test + public void testShortUnsafeSetValue() + { + short newValue = 6; + s.setValue( 0, newValue ); + assertEquals( newValue, s.getValue( 0 ) ); + } + + @Test + public void testShortUnsafeGetAddress() + { + assertEquals( address, s.getAddres() ); + } + +}