-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #719 from canthonyl/issue/705PR
#705 Add interfaces for MultiReader List/Set/Bag
- Loading branch information
Showing
18 changed files
with
365 additions
and
55 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
eclipse-collections-api/src/main/java/org/eclipse/collections/api/bag/MultiReaderBag.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,26 @@ | ||
/* | ||
* Copyright (c) 2019 Goldman Sachs and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.api.bag; | ||
|
||
import org.eclipse.collections.api.block.procedure.Procedure; | ||
|
||
/** | ||
* A MultiReaderBag provides thread-safe iteration for a bag through methods {@code withReadLockAndDelegate()} and {@code withWriteLockAndDelegate()}. | ||
* | ||
* @since 10.0. | ||
*/ | ||
public interface MultiReaderBag<T> | ||
extends MutableBag<T> | ||
{ | ||
void withReadLockAndDelegate(Procedure<? super MutableBag<T>> procedure); | ||
|
||
void withWriteLockAndDelegate(Procedure<? super MutableBag<T>> procedure); | ||
} |
63 changes: 63 additions & 0 deletions
63
...ions-api/src/main/java/org/eclipse/collections/api/factory/bag/MultiReaderBagFactory.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,63 @@ | ||
/* | ||
* Copyright (c) 2019 Goldman Sachs and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.api.factory.bag; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.eclipse.collections.api.bag.MultiReaderBag; | ||
|
||
/** | ||
* A factory which creates instances of type {@link MultiReaderBag}. | ||
* | ||
* @since 10.0. | ||
*/ | ||
public interface MultiReaderBagFactory | ||
{ | ||
<T> MultiReaderBag<T> empty(); | ||
|
||
/** | ||
* Same as {@link #empty()}. | ||
*/ | ||
default <T> MultiReaderBag<T> of() | ||
{ | ||
return this.empty(); | ||
} | ||
|
||
/** | ||
* Same as {@link #empty()}. | ||
*/ | ||
default <T> MultiReaderBag<T> with() | ||
{ | ||
return this.empty(); | ||
} | ||
|
||
/** | ||
* Same as {@link #with(Object[])}. | ||
*/ | ||
default <T> MultiReaderBag<T> of(T... elements) | ||
{ | ||
return this.with(elements); | ||
} | ||
|
||
<T> MultiReaderBag<T> with(T... elements); | ||
|
||
/** | ||
* Same as {@link #withAll(Iterable)}. | ||
*/ | ||
default <T> MultiReaderBag<T> ofAll(Iterable<? extends T> items) | ||
{ | ||
return this.withAll(items); | ||
} | ||
|
||
<T> MultiReaderBag<T> withAll(Iterable<? extends T> items); | ||
|
||
<T> MultiReaderBag<T> fromStream(Stream<? extends T> stream); | ||
} |
79 changes: 79 additions & 0 deletions
79
...ns-api/src/main/java/org/eclipse/collections/api/factory/list/MultiReaderListFactory.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,79 @@ | ||
/* | ||
* Copyright (c) 2019 Goldman Sachs and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.api.factory.list; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.eclipse.collections.api.block.function.Function0; | ||
import org.eclipse.collections.api.list.MultiReaderList; | ||
|
||
/** | ||
* A factory which creates instances of type {@link MultiReaderList}. | ||
* | ||
* @since 10.0. | ||
*/ | ||
public interface MultiReaderListFactory | ||
{ | ||
<T> MultiReaderList<T> empty(); | ||
|
||
/** | ||
* Same as {@link #empty()}. | ||
*/ | ||
default <T> MultiReaderList<T> of() | ||
{ | ||
return this.empty(); | ||
} | ||
|
||
/** | ||
* Same as {@link #empty()}. | ||
*/ | ||
default <T> MultiReaderList<T> with() | ||
{ | ||
return this.empty(); | ||
} | ||
|
||
/** | ||
* Same as {@link #with(Object[])}. | ||
*/ | ||
default <T> MultiReaderList<T> of(T... items) | ||
{ | ||
return this.with(items); | ||
} | ||
|
||
<T> MultiReaderList<T> with(T... items); | ||
|
||
/** | ||
* Same as {@link #empty()}. but takes in initial capacity. | ||
*/ | ||
default <T> MultiReaderList<T> ofInitialCapacity(int capacity) | ||
{ | ||
return this.withInitialCapacity(capacity); | ||
} | ||
|
||
/** | ||
* Same as {@link #empty()}. but takes in initial capacity. | ||
*/ | ||
<T> MultiReaderList<T> withInitialCapacity(int capacity); | ||
|
||
/** | ||
* Same as {@link #withAll(Iterable)}. | ||
*/ | ||
default <T> MultiReaderList<T> ofAll(Iterable<? extends T> iterable) | ||
{ | ||
return this.withAll(iterable); | ||
} | ||
|
||
<T> MultiReaderList<T> withAll(Iterable<? extends T> iterable); | ||
|
||
<T> MultiReaderList<T> fromStream(Stream<? extends T> stream); | ||
|
||
<T> MultiReaderList<T> withNValues(int size, Function0<? extends T> factory); | ||
} |
76 changes: 76 additions & 0 deletions
76
...ions-api/src/main/java/org/eclipse/collections/api/factory/set/MultiReaderSetFactory.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,76 @@ | ||
/* | ||
* Copyright (c) 2019 Goldman Sachs and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.api.factory.set; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.eclipse.collections.api.set.MultiReaderSet; | ||
|
||
/** | ||
* A factory which creates instances of type {@link MultiReaderSet}. | ||
* | ||
* @since 10.0. | ||
*/ | ||
public interface MultiReaderSetFactory | ||
{ | ||
<T> MultiReaderSet<T> empty(); | ||
|
||
/** | ||
* Same as {@link #empty()}. | ||
*/ | ||
default <T> MultiReaderSet<T> of() | ||
{ | ||
return this.empty(); | ||
} | ||
|
||
/** | ||
* Same as {@link #empty()}. | ||
*/ | ||
default <T> MultiReaderSet<T> with() | ||
{ | ||
return this.empty(); | ||
} | ||
|
||
/** | ||
* Same as {@link #with(Object[])}. | ||
*/ | ||
default <T> MultiReaderSet<T> of(T... items) | ||
{ | ||
return this.with(items); | ||
} | ||
|
||
<T> MultiReaderSet<T> with(T... items); | ||
|
||
/** | ||
* Same as {@link #empty()}. but takes in initial capacity. | ||
*/ | ||
default <T> MultiReaderSet<T> ofInitialCapacity(int capacity) | ||
{ | ||
return this.withInitialCapacity(capacity); | ||
} | ||
|
||
/** | ||
* Same as {@link #empty()}. but takes in initial capacity. | ||
*/ | ||
<T> MultiReaderSet<T> withInitialCapacity(int capacity); | ||
|
||
/** | ||
* Same as {@link #withAll(Iterable)}. | ||
*/ | ||
default <T> MultiReaderSet<T> ofAll(Iterable<? extends T> items) | ||
{ | ||
return this.withAll(items); | ||
} | ||
|
||
<T> MultiReaderSet<T> withAll(Iterable<? extends T> items); | ||
|
||
<T> MultiReaderSet<T> fromStream(Stream<? extends T> stream); | ||
} |
26 changes: 26 additions & 0 deletions
26
eclipse-collections-api/src/main/java/org/eclipse/collections/api/list/MultiReaderList.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,26 @@ | ||
/* | ||
* Copyright (c) 2019 Goldman Sachs and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.api.list; | ||
|
||
import org.eclipse.collections.api.block.procedure.Procedure; | ||
|
||
/** | ||
* A MultiReaderList provides thread-safe iteration for a list through methods {@code withReadLockAndDelegate()} and {@code withWriteLockAndDelegate()}. | ||
* | ||
* @since 10.0. | ||
*/ | ||
public interface MultiReaderList<T> | ||
extends MutableList<T> | ||
{ | ||
void withReadLockAndDelegate(Procedure<? super MutableList<T>> procedure); | ||
|
||
void withWriteLockAndDelegate(Procedure<? super MutableList<T>> procedure); | ||
} |
26 changes: 26 additions & 0 deletions
26
eclipse-collections-api/src/main/java/org/eclipse/collections/api/set/MultiReaderSet.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,26 @@ | ||
/* | ||
* Copyright (c) 2019 Goldman Sachs and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v. 1.0 which accompany this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
*/ | ||
|
||
package org.eclipse.collections.api.set; | ||
|
||
import org.eclipse.collections.api.block.procedure.Procedure; | ||
|
||
/** | ||
* A MultiReaderSet provides thread-safe iteration for a set through methods {@code withReadLockAndDelegate()} and {@code withWriteLockAndDelegate()}. | ||
* | ||
* @since 10.0. | ||
*/ | ||
public interface MultiReaderSet<T> | ||
extends MutableSet<T> | ||
{ | ||
void withReadLockAndDelegate(Procedure<? super MutableSet<T>> procedure); | ||
|
||
void withWriteLockAndDelegate(Procedure<? super MutableSet<T>> procedure); | ||
} |
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
Oops, something went wrong.