Skip to content

Commit 34ed457

Browse files
committed
Merge branch 'master' of github.com:mtransitapps/parser
2 parents cb8772d + 9a2b6a4 commit 34ed457

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2000
-1327
lines changed

.github/workflows/mt-build-module.yml

Lines changed: 0 additions & 111 deletions
This file was deleted.

.github/workflows/mt-build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: MT build
2+
on:
3+
workflow_dispatch: # manual
4+
pull_request:
5+
push:
6+
branches:
7+
# - '**' # ALL
8+
- 'master'
9+
# TODO 'develop', 'main'?
10+
# gh workflow run mt-build.yml --ref <branch>
11+
# gh run list --workflow=mt-build.yml
12+
jobs:
13+
MT-MAIN-REPO-BUILD-JOB:
14+
uses: mtransitapps/mtransit-for-android/.github/workflows/mt-build.yml@master
15+
secrets: inherit

src/main/java/org/mtransit/commons/CollectionsExt.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,45 @@ fun <T> Iterable<T>.matchList(
191191
thisPrefixLength > thisSuffixLength -> thisPrefixLength
192192
else -> thisSuffixLength
193193
}).toFloat().div(otherLength) + ignoredMatchPt
194+
}
195+
196+
fun <T> Iterable<T>.hasItemsGoingIntoSameOrder(otherIt: Iterable<T>): Boolean {
197+
return this.countItemsGoingIntoSameOrder(otherIt, firstItemsOnly = true) > 0
198+
}
199+
200+
fun <T> Iterable<T>.countItemsGoingIntoSameOrder(otherIt: Iterable<T>, firstItemsOnly: Boolean = false): Int {
201+
val thisList = this as? List<T> ?: this.toList()
202+
val otherList = otherIt as? List<T> ?: otherIt.toList()
203+
var count = 0
204+
var thisIndex = 0
205+
var otherStartIndex = 0
206+
while (thisIndex < thisList.size) {
207+
val otherMatchIndex = otherList.indexOf(thisList[thisIndex], otherStartIndex)
208+
if (otherMatchIndex != -1) {
209+
var len = 1
210+
while (thisIndex + len < thisList.size &&
211+
otherMatchIndex + len < otherList.size &&
212+
thisList[thisIndex + len] == otherList[otherMatchIndex + len]) {
213+
len++
214+
}
215+
if (len > 1) {
216+
count += len
217+
if (firstItemsOnly) return count
218+
thisIndex += len
219+
otherStartIndex = otherMatchIndex + len
220+
continue
221+
}
222+
}
223+
thisIndex++
224+
}
225+
return count
226+
}
227+
228+
fun <T> List<T>.indexOf(element: T, startIndex: Int): Int {
229+
for (i in startIndex until this.size) {
230+
if (this[i] == element) {
231+
return i
232+
}
233+
}
234+
return -1
194235
}

src/main/java/org/mtransit/parser/Constants.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ public final class Constants {
2222

2323
public static final char SPACE = ' ';
2424

25-
public static final char COLUMN_SEPARATOR = ',';
26-
27-
public static final char STRING_DELIMITER = '\'';
28-
2925
public static final String EMPTY = "";
3026

3127
public static final String SPACE_ = " ";

0 commit comments

Comments
 (0)