nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f571b46
)
poset: introduce POSet::linearize
author
Alexandre Terrasa
<alexandre@moz-code.org>
Thu, 8 May 2014 00:28:03 +0000
(20:28 -0400)
committer
Alexandre Terrasa
<alexandre@moz-code.org>
Thu, 8 May 2014 01:28:14 +0000
(21:28 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
lib/poset.nit
patch
|
blob
|
history
diff --git
a/lib/poset.nit
b/lib/poset.nit
index
65695da
..
ac0765e
100644
(file)
--- a/
lib/poset.nit
+++ b/
lib/poset.nit
@@
-163,6
+163,13
@@
class POSet[E: Object]
if res != 0 then return res
return elements[a].count <=> elements[b].count
end
+
+ # Sort a sorted array of poset elements using linearization order
+ fun linearize(elements: Collection[E]): Array[E] do
+ var lin = elements.to_a
+ sort(lin)
+ return lin
+ end
end
# View of an objet in a poset