Skip to content

Commit 6534897

Browse files
committed
WebTimer - Minor changes for a daemon thread option
MapUtils - Multiple maps merge method added
1 parent 47dcd45 commit 6534897

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

modules/core/src/com/alee/utils/MapUtils.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,36 @@ public static <K, V> void removeAllValues ( final Map<K, V> map, final V value )
272272
}
273273
}
274274
}
275+
276+
/**
277+
* Merges specified maps into one new map and returns it.
278+
*
279+
* @param maps maps to merge into new one
280+
* @param <K> key type
281+
* @param <V> value type
282+
* @return new map containing all provided maps merged into it
283+
*/
284+
public static <K, V> HashMap<K, V> merge ( final Map<K, V>... maps )
285+
{
286+
// Preparing new map size
287+
int size = 0;
288+
for ( final Map<K, V> map : maps )
289+
{
290+
if ( map != null )
291+
{
292+
size += map.size ();
293+
}
294+
}
295+
296+
// Creating and filling new map
297+
final HashMap<K, V> merged = new HashMap<K, V> ( size );
298+
for ( final Map<K, V> map : maps )
299+
{
300+
if ( map != null )
301+
{
302+
merged.putAll ( map );
303+
}
304+
}
305+
return merged;
306+
}
275307
}

modules/core/src/com/alee/utils/swing/WebTimer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ public static WebTimer repeat ( final boolean useDaemonThread, final String name
15061506
final WebTimer repeat = new WebTimer ( name, delay, initialDelay, listener );
15071507
repeat.setRepeats ( true );
15081508
repeat.setUseDaemonThread ( useDaemonThread );
1509+
repeat.setUseEventDispatchThread ( false );
15091510
repeat.setCyclesLimit ( cyclesLimit );
15101511
repeat.start ();
15111512
return repeat;

0 commit comments

Comments
 (0)