1 /*
2 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
3 * reserved.
4 * $COPYRIGHT$
5 *
6 * Additional copyrights may follow
7 *
8 * $HEADER$
9 *
10 *
11 * This file is almost a complete re-write for Open MPI compared to the
12 * original mpiJava package. Its license and copyright are listed below.
13 * See <path to ompi/mpi/java/README> for more information.
14 *
15 *
16 * Licensed under the Apache License, Version 2.0 (the "License");
17 * you may not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 *
28 *
29 * File : Count.java
30 * Author : Nathaniel Graham
31 * Created : Thu Jul 29 17:13 2015
32 */
33
34 package mpi;
35
36 /**
37 * This class represents {@code MPI_Count}.
38 */
39 public final class Count implements Comparable
40 {
41 private long count;
42
43 static
44 {
45 System.loadLibrary("mpi_java");
46 initCount();
47 }
48
49 private static native void initCount();
50
51 public Count(long count)
52 {
53 this.count = count;
54 }
55
56 /**
57 * Gets value associated with this Count object.
58 * @return Count value
59 */
60 public long getCount()
61 {
62 return this.count;
63 }
64
65 /**
66 * Sets the value associated with this Count object.
67 * @param count the value to set for this count object
68 */
69 public void setCount(long count)
70 {
71 this.count = count;
72 }
73
74 @Override
75 public boolean equals(Object obj)
76 {
77 if(obj instanceof Count) {
78 if(this.count == ((Count)obj).getCount()) {
79 return true;
80 }
81 }
82 return false;
83 }
84
85 public int compareTo(Object obj)
86 {
87 if(obj instanceof Count) {
88 if(this.count - ((Count)obj).getCount() > 0) {
89 return 1;
90 } else if(this.count - ((Count)obj).getCount() == 0) {
91 return 0;
92 }
93 }
94 return -1;
95 }
96 } // Count