1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Remove duplicates from a character array
///
/// Remove duplicate elements from a character array.
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// NELT I-O Number of elements in the array.
/// ARRAY I-O Input/output array.
/// ```
///
/// # Detailed Input
///
/// ```text
/// NELT on input is the number of elements in the input
/// array.
///
/// ARRAY on input contains zero or more elements, from which
/// all duplicate elements are to be removed.
/// ```
///
/// # Detailed Output
///
/// ```text
/// NELT on output is the number of elements in the output
/// array.
///
/// ARRAY on output contains the distinct elements of the
/// input array, sorted in increasing order. (Character
/// arrays are sorted according to the ASCII collating
/// sequence).
/// ```
///
/// # Exceptions
///
/// ```text
/// Error free.
/// ```
///
/// # Examples
///
/// ```text
/// Let the arrays C and I contain the following elements.
///
/// NC = 7 NI = 5
/// C(1) = 'Miranda' I(1) = 13
/// C(2) = 'Ariel' I(2) = -13
/// C(3) = 'Umbriel' I(3) = 0
/// C(4) = 'Titania' I(4) = 1
/// C(5) = 'Miranda' I(5) = 0
/// C(6) = 'Oberon'
/// C(7) = 'Umbriel'
///
/// Then following the calls
///
/// CALL RMDUPC ( NC, C )
/// CALL RMDUPI ( NI, I )
///
/// C and I contain the following.
///
/// NC = 5 NI = 4
/// C(1) = 'Ariel' I(1) = -13
/// C(2) = 'Miranda' I(2) = 0
/// C(3) = 'Oberon' I(3) = 1
/// C(4) = 'Titania' I(4) = 13
/// C(5) = 'Umbriel'
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// W.L. Taber (JPL)
/// I.M. Underwood (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 05-JUN-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 1.0.0, 31-JAN-1990 (IMU)
/// ```
pub fn rmdupc(nelt: &mut i32, array: CharArrayMut) {
RMDUPC(nelt, array);
}
//$Procedure RMDUPC ( Remove duplicates from a character array )
pub fn RMDUPC(NELT: &mut i32, ARRAY: CharArrayMut) {
let mut ARRAY = DummyCharArrayMut::new(ARRAY, None, 1..);
let mut J: i32 = 0;
//
// Local variables
//
//
// Proceed only if the array actually contains more than one element.
//
if (*NELT > 1) {
//
// Sort the array in place.
//
SHELLC(*NELT, ARRAY.as_arg_mut());
//
// Drop duplicate entries. Compare adjacent entries, and move
// duplicates forward. (Duplicates are now adjacent, because of
// sorting.)
//
J = 1;
for I in 2..=*NELT {
if fstr::ne(ARRAY.get(I), ARRAY.get((I - 1))) {
J = (J + 1);
let val = ARRAY.get(I).to_vec();
fstr::assign(ARRAY.get_mut(J), &val);
}
}
*NELT = J;
}
}