Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,73 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref savelog symbols binary
|
||||
|
||||
import java.util.List
|
||||
|
||||
placesList = [String -
|
||||
"UK London", "US New York", "US Boston", "US Washington" -
|
||||
, "UK Washington", "US Birmingham", "UK Birmingham", "UK Boston" -
|
||||
]
|
||||
|
||||
lists = [ -
|
||||
placesList -
|
||||
, strandSort(String[] Arrays.copyOf(placesList, placesList.length)) -
|
||||
]
|
||||
|
||||
loop ln = 0 to lists.length - 1
|
||||
cl = lists[ln]
|
||||
loop ct = 0 to cl.length - 1
|
||||
say cl[ct]
|
||||
end ct
|
||||
say
|
||||
end ln
|
||||
|
||||
return
|
||||
|
||||
method strandSort(A = String[]) public constant binary returns String[]
|
||||
|
||||
rl = String[A.length]
|
||||
al = List strandSort(Arrays.asList(A))
|
||||
al.toArray(rl)
|
||||
|
||||
return rl
|
||||
|
||||
method strandSort(Alst = List) public constant binary returns ArrayList
|
||||
|
||||
A = ArrayList(Alst)
|
||||
result = ArrayList()
|
||||
loop label A_ while A.size > 0
|
||||
sublist = ArrayList()
|
||||
sublist.add(A.get(0))
|
||||
A.remove(0)
|
||||
loop i_ = 0 while i_ < A.size - 1
|
||||
if (Comparable A.get(i_)).compareTo(Comparable sublist.get(sublist.size - 1)) > 0 then do
|
||||
sublist.add(A.get(i_))
|
||||
A.remove(i_)
|
||||
end
|
||||
end i_
|
||||
result = merge(result, sublist)
|
||||
end A_
|
||||
|
||||
return result
|
||||
|
||||
method merge(left = List, right = List) public constant binary returns ArrayList
|
||||
|
||||
result = ArrayList()
|
||||
loop label mx while left.size > 0 & right.size > 0
|
||||
if (Comparable left.get(0)).compareTo(Comparable right.get(0)) <= 0 then do
|
||||
result.add(left.get(0))
|
||||
left.remove(0)
|
||||
end
|
||||
else do
|
||||
result.add(right.get(0))
|
||||
right.remove(0)
|
||||
end
|
||||
end mx
|
||||
if left.size > 0 then do
|
||||
result.addAll(left)
|
||||
end
|
||||
if right.size > 0 then do
|
||||
result.addAll(right)
|
||||
end
|
||||
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue