From 3ea342ad198dbb915d1b6a1728b0bad8a1090ed3 Mon Sep 17 00:00:00 2001 From: "Scott L. Burson" Date: Tue, 15 Mar 2016 15:05:32 -0700 Subject: [PATCH] New convenience methods: `FLinkedHashSet.toList`, `FLinkedHashMap.keyList`. --- com/ergy/fset/FLinkedHashMap.java | 10 +++++++++- com/ergy/fset/FLinkedHashSet.java | 14 +++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/com/ergy/fset/FLinkedHashMap.java b/com/ergy/fset/FLinkedHashMap.java index 34fba9f..3224bcf 100644 --- a/com/ergy/fset/FLinkedHashMap.java +++ b/com/ergy/fset/FLinkedHashMap.java @@ -24,7 +24,8 @@ * *

WARNING: less takes O(n) time in this implementation. Avoid it. * - *

Still unimplemented: restrictedTo, restrictedFrom. + *

Still unimplemented: user-supplied comparators; restrictedTo, + * restrictedFrom. */ public class FLinkedHashMap @@ -74,6 +75,13 @@ public int size() { return FHashMap.treeSize(map_tree); } + /** + * Returns the keys in the map, in order, as an FList. + */ + public FList keyList() { + return new FTreeList(list_tree, null); + } + public Map.Entry arb() { return (Map.Entry)FHashMap.arb(map_tree); } diff --git a/com/ergy/fset/FLinkedHashSet.java b/com/ergy/fset/FLinkedHashSet.java index f669867..7cf7c85 100644 --- a/com/ergy/fset/FLinkedHashSet.java +++ b/com/ergy/fset/FLinkedHashSet.java @@ -18,13 +18,14 @@ /** - * Just like FHashSet except that the iterator returns entries - * in the same order in which the keys were first added. + * Just like FHashSet except that the iterator returns elements + * in the same order in which they were first added. * *

WARNING: less takes O(n) time, in general, in this implementation. * Avoid it, except in the special case of the element just returned by arb. * - * Still unimplemented: intersection, difference. + * Still unimplemented: user-supplied comparators; intersection, + * difference. */ public class FLinkedHashSet @@ -64,6 +65,13 @@ public int size() { return FHashSet.treeSize(set_tree); } + /** + * Returns the contents of the set, in order, as an FList. + */ + public FList toList() { + return new FTreeList(list_tree, null); + } + /** * On an FLinkedHashSet, always returns the element that was added first. * (A subsequent call to less passing this element will be efficient.)