1 /* 2 3 dsh-matrix-nonblocking Non-blocking matrix implementations. 4 Copyright (c) 2010-2013 held jointly by the individual authors. 5 6 This library is free software; you can redistribute it and/or modify it 7 under the terms of the GNU Lesser General Public License as published 8 by the Free Software Foundation; either version 3 of the License, or (at 9 your option) any later version. 10 11 This library is distributed in the hope that it will be useful, but WITHOUT 12 ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 License for more details. 15 16 You should have received a copy of the GNU Lesser General Public License 17 along with this library; if not, write to the Free Software Foundation, 18 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 19 20 > http://www.fsf.org/licensing/licenses/lgpl.html 21 > http://www.opensource.org/licenses/lgpl-license.php 22 23 */ 24 package org.dishevelled.matrix.impl.nonblocking; 25 26 import java.util.Map; 27 28 //import static org.dishevelled.collect.Maps.*; 29 import org.dishevelled.collect.Maps; 30 31 import org.dishevelled.matrix.impl.SparseMatrix3D; 32 33 /** 34 * Non-blocking sparse implementation of Matrix3D. 35 * 36 * @param <E> element type 37 * @author Michael Heuer 38 * @version $Revision$ $Date$ 39 */ 40 public class NonBlockingSparseMatrix3D<E> 41 extends SparseMatrix3D<E> 42 { 43 44 /** 45 * Create a new non-blocking sparse 3D matrix with the specified number 46 * of slices, rows, and columns, and initial capacity. 47 * 48 * @param slices slices, must be <code>>= 0</code> 49 * @param rows rows, must be <code>>= 0</code> 50 * @param columns columns, must be <code>>= 0</code> 51 * @param initialCapacity initial capacity, must be <code>>= 0</code> 52 */ 53 public NonBlockingSparseMatrix3D(final long slices, 54 final long rows, 55 final long columns, 56 final int initialCapacity) 57 { 58 this(slices, rows, columns, 59 0L, 0L, 0L, rows * columns, columns, 1L, 60 false, Maps.<E>createLongNonBlockingMap(initialCapacity)); 61 } 62 63 /** 64 * Create a new instance of NonBlockingSparseMatrix3D with the specified 65 * parameters and map of elements. 66 * 67 * @param slices slices, must be <code>>= 0</code> 68 * @param rows rows, must be <code>>= 0</code> 69 * @param columns columns, must be <code>>= 0</code> 70 * @param sliceZero slice of the first element 71 * @param rowZero row of the first element 72 * @param columnZero column of the first element 73 * @param sliceStride number of slices between two elements 74 * @param rowStride number of rows between two elements 75 * @param columnStride number of columns between two elements 76 * @param isView true if this instance is a view 77 * @param elements map of elements 78 */ 79 protected NonBlockingSparseMatrix3D(final long slices, 80 final long rows, 81 final long columns, 82 final long sliceZero, 83 final long rowZero, 84 final long columnZero, 85 final long sliceStride, 86 final long rowStride, 87 final long columnStride, 88 final boolean isView, 89 final Map<Long, E> elements) 90 { 91 super(slices, rows, columns, 92 sliceZero, rowZero, columnZero, 93 sliceStride, rowStride, columnStride, isView, elements); 94 } 95 96 97 /** {@inheritDoc} */ 98 public Object clone() 99 { 100 return new NonBlockingSparseMatrix3D<E>(slices(), rows(), columns(), 101 sliceZero(), rowZero(), columnZero(), 102 sliceStride(), rowStride(), columnStride(), 103 isView(), elements()); 104 } 105 106 // todo: override to prevent autoboxing where necessary 107 }