SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
OneDimSort.java
1
/*
2
* Class: OneDimSort
3
* Description: Sorts the arrays according to one dimension
4
* Environment: Java
5
* Software: SSJ
6
* Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7
* Organization: DIRO, Universite de Montreal
8
* @author
9
* @since
10
11
* SSJ is free software: you can redistribute it and/or modify it under
12
* the terms of the GNU General Public License (GPL) as published by the
13
* Free Software Foundation, either version 3 of the License, or
14
* any later version.
15
16
* SSJ is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
20
21
* A copy of the GNU General Public License is available at
22
<a href="http://www.gnu.org/licenses">GPL licence site</a>.
23
*/
24
package
umontreal.ssj.util.multidimsort;
25
26
import
java.util.Arrays;
27
43
public
class
OneDimSort
<T
extends
MultiDimComparable
<? super T>> implements
MultiDimSortComparable
<T> {
44
private
int
j;
45
private
int
d;
46
53
public
OneDimSort
(
int
j,
int
d) {
54
if
(j < 0 || j >= d)
55
throw
new
IllegalArgumentException(
"sortCoordinate from 0 to "
+ d +
" - 1."
);
56
this.j = j;
57
this.d = d;
58
}
59
65
public
OneDimSort
(
int
j) {
66
this
(j, j + 1);
67
// this(d - 1, d);
68
}
69
70
public
void
sort(T[] a,
int
iMin,
int
iMax) {
71
Arrays.sort(a, iMin, iMax,
new
MultiDimComparator<T>
(j));
72
}
73
74
public
void
sort(T[] a) {
75
sort(a, 0, a.length);
76
}
77
78
public
void
sort(
double
[][] a,
int
iMin,
int
iMax) {
79
Arrays.sort(a, iMin, iMax,
new
DoubleArrayComparator(j));
80
}
81
82
public
void
sort(
double
[][] a) {
83
sort(a, 0, a.length);
84
}
85
91
public
int
getSortCoordinate
() {
92
return
j;
93
}
94
100
public
int
dimension
() {
101
return
d;
102
}
103
109
public
String
toString
() {
110
return
this.getClass().getSimpleName() +
": d = "
+ d +
", sort coordinate (starts at 0) = "
+ j;
111
}
112
113
}
umontreal.ssj.util.multidimsort.MultiDimComparator
This class is useful if one wishes to perform an ordinary one-dimensional sort on MultiDimComparable<...
Definition
MultiDimComparator.java:42
umontreal.ssj.util.multidimsort.OneDimSort.getSortCoordinate
int getSortCoordinate()
Returns the coordinate used for sorting.
Definition
OneDimSort.java:91
umontreal.ssj.util.multidimsort.OneDimSort.OneDimSort
OneDimSort(int j, int d)
Constructs a OneDimSort object that will sort the.
Definition
OneDimSort.java:53
umontreal.ssj.util.multidimsort.OneDimSort.OneDimSort
OneDimSort(int j)
Constructs a OneDimSort that will sort the objects with respect to their coordinate .
Definition
OneDimSort.java:65
umontreal.ssj.util.multidimsort.OneDimSort.toString
String toString()
Returns a String containing information about this object.
Definition
OneDimSort.java:109
umontreal.ssj.util.multidimsort.OneDimSort.dimension
int dimension()
Returns the dimension of the states to be sorted.
Definition
OneDimSort.java:100
umontreal.ssj.util.multidimsort.MultiDimComparable
This interface is an extension (or variant) of the Comparable interface in Java.
Definition
MultiDimComparable.java:56
umontreal.ssj.util.multidimsort.MultiDimSortComparable
This interface extends MultiDimSort<T> to implement multivariate sorting algorithms that sort objects...
Definition
MultiDimSortComparable.java:42
src
main
java
umontreal
ssj
util
multidimsort
OneDimSort.java
Generated by
1.16.1