@@ -131,27 +131,6 @@ func (lt T) Copy() T {
131
131
return T {path : copiedLabels }
132
132
}
133
133
134
- // Prev returns the lexicographically previous LTree and a bool
135
- // indicating whether it exists.
136
- func (lt T ) Prev () (T , bool ) {
137
- if lt .Len () == 0 {
138
- return Empty , false
139
- }
140
-
141
- lastLabel := lt .path [lt .Len ()- 1 ]
142
- if l := prevLabel (lastLabel ); l != "" {
143
- result := lt .Copy ()
144
- result .path [lt .Len ()- 1 ] = l
145
- return result , true
146
- }
147
-
148
- if lt .Len () > 1 {
149
- return T {path : lt .path [:lt .Len ()- 1 ]}, true
150
- }
151
-
152
- return Empty , true
153
- }
154
-
155
134
// validateLabel checks if a label is valid and returns an error if it is not,
156
135
// otherwise, it returns nil.
157
136
// A label is valid if it:
@@ -173,43 +152,7 @@ func validateLabel(l string) error {
173
152
return nil
174
153
}
175
154
176
- // prevLabel returns the lexicographically previous label or empty string if
177
- // none exists.
178
- func prevLabel (s string ) string {
179
- if len (s ) == 0 {
180
- return ""
181
- }
182
-
183
- lastChar := s [len (s )- 1 ]
184
- if prev := prevChar (lastChar ); prev != 0 {
185
- return s [:len (s )- 1 ] + string (prev )
186
- }
187
-
188
- if len (s ) > 1 {
189
- return s [:len (s )- 1 ]
190
- }
191
-
192
- return ""
193
- }
194
-
195
155
// isValidChar returns true if the character is valid in an LTree label.
196
156
func isValidChar (c byte ) bool {
197
157
return (c >= '0' && c <= '9' ) || (c >= 'a' && c <= 'z' ) || (c >= 'A' && c <= 'Z' ) || (c == '_' ) || (c == '-' )
198
158
}
199
-
200
- var prevCharMap = map [byte ]byte {
201
- '-' : 0 ,
202
- '0' : '-' ,
203
- 'A' : '9' ,
204
- '_' : 'Z' ,
205
- 'a' : '_' ,
206
- }
207
-
208
- // prevChar returns the previous valid character assuming a given valid
209
- // character, or 0 if none exists.
210
- func prevChar (c byte ) byte {
211
- if prev , ok := prevCharMap [c ]; ok {
212
- return prev
213
- }
214
- return c - 1
215
- }
0 commit comments