Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
ee541ba7
Commit
ee541ba7
authored
17 years ago
by
felmer
Browse files
Options
Downloads
Patches
Plain Diff
- add Javadoc for TableMap
- rename a method of TableMap SVN: 2066
parent
e6e3a029
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/collections/TableMap.java
+20
-2
20 additions, 2 deletions
...ce/java/ch/systemsx/cisd/common/collections/TableMap.java
with
20 additions
and
2 deletions
common/source/java/ch/systemsx/cisd/common/collections/TableMap.java
+
20
−
2
View file @
ee541ba7
...
...
@@ -22,7 +22,7 @@ import java.util.LinkedHashMap;
import
java.util.Map
;
/**
*
*
A table of rows of type <code>E</code> with random access via a key of type <code>K</code>.
*
* @author Franz-Josef Elmer
*/
...
...
@@ -31,8 +31,16 @@ public class TableMap<K, E> implements Iterable<E>
private
final
Map
<
K
,
E
>
map
=
new
LinkedHashMap
<
K
,
E
>();
private
final
IKeyExtractor
<
K
,
E
>
extractor
;
/**
* Creates a new instance for the specified rows and key extractor.
*
* @param rows Collection of rows of type <code>E</code>.
* @param extractor Strategy to extract a key of type <code>E</code> for an object of type <code>E</code>.
*/
public
TableMap
(
Collection
<
E
>
rows
,
IKeyExtractor
<
K
,
E
>
extractor
)
{
assert
rows
!=
null
:
"Unspecified collection of rows."
;
assert
extractor
!=
null
:
"Unspecified key extractor."
;
this
.
extractor
=
extractor
;
for
(
E
row
:
rows
)
{
...
...
@@ -40,16 +48,26 @@ public class TableMap<K, E> implements Iterable<E>
}
}
/**
* Adds the specified row to this table. An already existing row with the same key as <code>row</code> will be
* replaced by <code>row</code>.
*/
public
void
add
(
E
row
)
{
map
.
put
(
extractor
.
getKey
(
row
),
row
);
}
public
E
get
(
K
key
)
/**
* Gets the row for the specified key or <code>null</code> if not found.
*/
public
E
tryToGet
(
K
key
)
{
return
map
.
get
(
key
);
}
/**
* Creates an iterator of the rows in the order they have been added. Removing is not supported.
*/
public
Iterator
<
E
>
iterator
()
{
return
new
Iterator
<
E
>()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment