-
Notifications
You must be signed in to change notification settings - Fork 108
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
1 changed file
with
12 additions
and
0 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 |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* ConcurrentSet provides a Set that is thread-safe, usable in highly concurrent environments. It provides | ||
* a no-arg constructor that will directly return a ConcurrentSet that is thread-safe. It has a constructor | ||
* that takes a Collection argument and populates its internal Concurrent Set delegate implementation. | ||
* <br> | ||
* @author John DeRegnaucourt ([email protected]) | ||
* <br> | ||
* Copyright (c) Cedar Software LLC | ||
|
@@ -25,10 +29,18 @@ | |
public class ConcurrentSet<T> implements Set<T> { | ||
private final Set<T> set; | ||
|
||
/** | ||
* Create a new empty ConcurrentSet. | ||
*/ | ||
public ConcurrentSet() { | ||
set = ConcurrentHashMap.newKeySet(); | ||
} | ||
|
||
/** | ||
* Create a new ConcurrentSet instance with data from the passed in Collection. This data is populated into the | ||
* internal set. | ||
* @param col | ||
*/ | ||
public ConcurrentSet(Collection<T> col) { | ||
set = ConcurrentHashMap.newKeySet(col.size()); | ||
set.addAll(col); | ||
|