-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
188 changed files
with
11,287 additions
and
1,116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ hs_err_pid* | |
# Eclipse project information generated by Maven | ||
.classpath | ||
.project | ||
test-output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/demo/java/org/codefx/libfx/collection/transform/EqualityTransformingSetDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.codefx.libfx.collection.transform; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Demonstrates how to use the {@link EqualityTransformingSet}. | ||
* <p> | ||
* The demonstrated example is based on the situation that we want a set of strings which uses only their length for | ||
* equality comparison. | ||
*/ | ||
public class EqualityTransformingSetDemo { | ||
|
||
/** | ||
* A set of strings which uses the length for equality. | ||
*/ | ||
private final Set<String> lengthSet; | ||
|
||
/** | ||
* Creates a new demo. | ||
*/ | ||
public EqualityTransformingSetDemo() { | ||
lengthSet = EqualityTransformingCollectionBuilder | ||
.forType(String.class) | ||
.withEquals((a, b) -> a.length() == b.length()) | ||
.withHash(String::length) | ||
.buildSet(); | ||
} | ||
|
||
/** | ||
* Runs this demo. | ||
* | ||
* @param args | ||
* command line arguments (will not be used) | ||
*/ | ||
public static void main(String[] args) { | ||
EqualityTransformingSetDemo demo = new EqualityTransformingSetDemo(); | ||
|
||
demo.addSomeElements(); | ||
} | ||
|
||
private void addSomeElements() { | ||
print("-- Adding some elements --"); | ||
print(); | ||
|
||
lengthSet.add("a"); | ||
lengthSet.add("b"); | ||
print(lengthSet.toString()); | ||
} | ||
|
||
private static void print() { | ||
System.out.println(); | ||
} | ||
|
||
private static void print(String text) { | ||
System.out.println(text); | ||
} | ||
|
||
} |
Oops, something went wrong.