Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
WS4D
jCoAP
Commits
6dea83de
Commit
6dea83de
authored
Jul 04, 2016
by
Björn Butzin
Browse files
Added more code documentation to TimeoutHashMap2
parent
557d656d
Changes
1
Hide whitespace changes
Inline
Side-by-side
ws4d-jcoap/src/org/ws4d/coap/tools/TimeoutHashMap2.java
View file @
6dea83de
...
...
@@ -24,14 +24,39 @@ import java.util.Iterator;
import
java.util.Map
;
import
java.util.Set
;
/**
* This class provides a hash map implementation that automatically removes added items after a fixed amount of miliseconds.
*
* @author Bjrn Butzin <bjoern.butzin@uni-rostock.de>
*
* @param <K> the data type to be used as hash map key
* @param <V> the data type to be used as hash map value
*/
public
class
TimeoutHashMap2
<
K
,
V
>
implements
Map
<
K
,
V
>
{
/**
* This map that actually keeps the key value pairs.
* The original value is wrapped into a TimedEntry.
* A TimedEntry enhances the original value with the point in time when the item has to be deleted.
* This point in time is represented as milliseconds since the same point in time as used by System.currentTimeMillis().
*/
private
Map
<
K
,
TimedEntry
<
V
>>
map
=
new
Hashtable
<
K
,
TimedEntry
<
V
>>();
// the timeout of every new entry
/**
* the timeout of every new entry in ms
*/
private
Long
timeout
;
// this timer calls the update method when the next entry is timed out
/**
* this timer calls the update method when the next entry is timed out
*/
private
Thread
thread
=
new
Thread
(
new
TimeoutHashMapTimer
(
this
));
/**
* Creates a new TimeoutHashMap2 object
* @param timeout - the amount of milliseconds after which a newly added item will automatically be removed
*/
public
TimeoutHashMap2
(
long
timeout
)
{
this
.
timeout
=
timeout
;
this
.
thread
.
start
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment