View Javadoc

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.SparseMatrix2D;
32  
33  /**
34   * Non-blocking sparse implementation of Matrix2D.
35   *
36   * @param <E> element type
37   * @author  Michael Heuer
38   * @version $Revision$ $Date$
39   */
40  public class NonBlockingSparseMatrix2D<E>
41      extends SparseMatrix2D<E>
42  {
43  
44      /**
45       * Create a new non-blocking sparse 2D matrix with the specified number
46       * of rows and columns and initial capacity.
47       *
48       * @param rows rows, must be <code>&gt;= 0</code>
49       * @param columns columns, must be <code>&gt;= 0</code>
50       * @param initialCapacity initial capacity, must be <code>&gt;= 0</code>
51       */
52      public NonBlockingSparseMatrix2D(final long rows, final long columns, final int initialCapacity)
53      {
54          this(rows, columns, 0L, 0L, columns, 1L, false, Maps.<E>createLongNonBlockingMap(initialCapacity));
55      }
56  
57      /**
58       * Create a new instance of NonBlockingSparseMatrix2D with the specified
59       * parameters and map of elements.
60       *
61       * @param rows rows, must be <code>&gt;= 0</code>
62       * @param columns columns, must be <code>&gt;= 0</code>
63       * @param rowZero row of the first element
64       * @param columnZero column of the first element
65       * @param rowStride number of rows between two elements
66       * @param columnStride number of columns between two elements
67       * @param isView true if this instance is a view
68       * @param elements map of elements
69       */
70      protected NonBlockingSparseMatrix2D(final long rows,
71                                          final long columns,
72                                          final long rowZero,
73                                          final long columnZero,
74                                          final long rowStride,
75                                          final long columnStride,
76                                          final boolean isView,
77                                          final Map<Long, E> elements)
78      {
79          super(rows, columns,
80                rowZero, columnZero,
81                rowStride, columnStride,
82                isView, elements);
83      }
84  
85  
86      /** {@inheritDoc} */
87      public Object clone()
88      {
89          return new NonBlockingSparseMatrix2D<E>(rows(), columns(),
90                                                  rowZero(), columnZero(),
91                                                  rowStride(), columnStride(),
92                                                  isView(), elements());
93      }
94  
95      // todo:  override to prevent autoboxing where necessary
96  }