forked from eclipse/eclipse-collections
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eclipse#705 Add specialised interfaces for MultiReader List Set and Bag
- Loading branch information
Showing
19 changed files
with
347 additions
and
47 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
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,13 @@ | ||
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()}. | ||
* | ||
*/ | ||
public interface MultiReaderBag<T> extends MutableBag<T> { | ||
|
||
void withReadLockAndDelegate(Procedure<MutableBag<T>> procedure); | ||
|
||
void withWriteLockAndDelegate(Procedure<MutableBag<T>> procedure); | ||
} |
67 changes: 67 additions & 0 deletions
67
...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,67 @@ | ||
/* | ||
* 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}. | ||
*/ | ||
public interface MultiReaderBagFactory | ||
{ | ||
/** | ||
* @since 6.0 | ||
*/ | ||
<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); | ||
|
||
/** | ||
* @since 10.0. | ||
*/ | ||
<T> MultiReaderBag<T> fromStream(Stream<? extends T> stream); | ||
} |
81 changes: 81 additions & 0 deletions
81
...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,81 @@ | ||
/* | ||
* 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; | ||
import org.eclipse.collections.api.list.MutableList; | ||
|
||
public interface MultiReaderListFactory | ||
{ | ||
/** | ||
* @since 6.0 | ||
*/ | ||
<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); | ||
|
||
/** | ||
* @since 10.0. | ||
*/ | ||
<T> MultiReaderList<T> fromStream(Stream<? extends T> stream); | ||
|
||
<T> MultiReaderList<T> withNValues(int size, Function0<? extends T> factory); | ||
} |
77 changes: 77 additions & 0 deletions
77
...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,77 @@ | ||
/* | ||
* 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; | ||
|
||
public interface MultiReaderSetFactory | ||
{ | ||
/** | ||
* @since 6.0 | ||
*/ | ||
<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); | ||
|
||
/** | ||
* @since 10.0. | ||
*/ | ||
<T> MultiReaderSet<T> fromStream(Stream<? extends T> stream); | ||
} |
15 changes: 15 additions & 0 deletions
15
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,15 @@ | ||
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()}. | ||
* | ||
*/ | ||
public interface MultiReaderList<T> extends MutableList<T>{ | ||
|
||
void withReadLockAndDelegate(Procedure<MutableList<T>> procedure); | ||
|
||
void withWriteLockAndDelegate(Procedure<MutableList<T>> procedure); | ||
} |
15 changes: 15 additions & 0 deletions
15
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,15 @@ | ||
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()}. | ||
* | ||
*/ | ||
public interface MultiReaderSet<T> extends MutableSet<T> { | ||
|
||
|
||
void withReadLockAndDelegate(Procedure<MutableSet<T>> procedure); | ||
|
||
void withWriteLockAndDelegate(Procedure<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
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.