Skip to content

Commit

Permalink
Merge branch 'master' of github.com:slburson/fset-java
Browse files Browse the repository at this point in the history
  • Loading branch information
slburson committed May 4, 2016
2 parents 435d094 + 3ea342a commit 3c35e58
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
10 changes: 9 additions & 1 deletion com/ergy/fset/FLinkedHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
*
* <p>WARNING: <code>less</code> takes O(n) time in this implementation. Avoid it.
*
* <p>Still unimplemented: <code>restrictedTo</code>, <code>restrictedFrom</code>.
* <p>Still unimplemented: user-supplied comparators; <code>restrictedTo</code>,
* <code>restrictedFrom</code>.
*/

public class FLinkedHashMap<Key, Val>
Expand Down Expand Up @@ -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<Key> keyList() {
return new FTreeList<Key>(list_tree, null);
}

public Map.Entry<Key, Val> arb() {
return (Map.Entry<Key, Val>)FHashMap.arb(map_tree);
}
Expand Down
14 changes: 11 additions & 3 deletions com/ergy/fset/FLinkedHashSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@


/**
* Just like <code>FHashSet</code> except that the iterator returns entries
* in the same order in which the keys were first added.
* Just like <code>FHashSet</code> except that the iterator returns elements
* in the same order in which they were first added.
*
* <p>WARNING: <code>less</code> takes O(n) time, in general, in this implementation.
* Avoid it, except in the special case of the element just returned by <code>arb</code>.
*
* Still unimplemented: <code>intersection</code>, <code>difference</code>.
* Still unimplemented: user-supplied comparators; <code>intersection</code>,
* <code>difference</code>.
*/

public class FLinkedHashSet<Elt>
Expand Down Expand Up @@ -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<Elt> toList() {
return new FTreeList<Elt>(list_tree, null);
}

/**
* On an <code>FLinkedHashSet</code>, always returns the element that was added first.
* (A subsequent call to <code>less</code> passing this element will be efficient.)
Expand Down

0 comments on commit 3c35e58

Please sign in to comment.