primitive map libraries
This commit is contained in:
		
							parent
							
								
									68f1cb23dd
								
							
						
					
					
						commit
						b42c2d3a5f
					
				| @ -373,6 +373,21 @@ | |||||||
|             <artifactId>eclipse-collections</artifactId> |             <artifactId>eclipse-collections</artifactId> | ||||||
|             <version>${eclipse-collections.version}</version> |             <version>${eclipse-collections.version}</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>net.sf.trove4j</groupId> | ||||||
|  |             <artifactId>trove4j</artifactId> | ||||||
|  |             <version>3.0.2</version> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>it.unimi.dsi</groupId> | ||||||
|  |             <artifactId>fastutil</artifactId> | ||||||
|  |             <version>8.1.0</version> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>colt</groupId> | ||||||
|  |             <artifactId>colt</artifactId> | ||||||
|  |             <version>1.2.0</version> | ||||||
|  |         </dependency> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>io.vavr</groupId> |             <groupId>io.vavr</groupId> | ||||||
|             <artifactId>vavr</artifactId> |             <artifactId>vavr</artifactId> | ||||||
|  | |||||||
| @ -0,0 +1,54 @@ | |||||||
|  | package com.baeldung.primitives; | ||||||
|  | 
 | ||||||
|  | import cern.colt.map.AbstractIntDoubleMap; | ||||||
|  | import cern.colt.map.OpenIntDoubleHashMap; | ||||||
|  | import gnu.trove.map.TDoubleIntMap; | ||||||
|  | import gnu.trove.map.hash.TDoubleIntHashMap; | ||||||
|  | import org.eclipse.collections.api.map.primitive.*; | ||||||
|  | import org.eclipse.collections.impl.factory.primitive.*; | ||||||
|  | 
 | ||||||
|  | public class PrimitiveMaps { | ||||||
|  | 
 | ||||||
|  |     public static void main(String[] args) { | ||||||
|  | 
 | ||||||
|  |         eclipseCollectionsMap(); | ||||||
|  |         troveMap(); | ||||||
|  |         coltMap(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private static void coltMap() { | ||||||
|  |         AbstractIntDoubleMap map = new OpenIntDoubleHashMap(); | ||||||
|  |         map.put(1, 4.5); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private static void eclipseCollectionsMap() { | ||||||
|  |         MutableObjectDoubleMap<String> doubleMap = ObjectDoubleMaps.mutable.empty(); | ||||||
|  |         doubleMap.put("1", 1.0d); | ||||||
|  |         doubleMap.put("2", 2.0d); | ||||||
|  | 
 | ||||||
|  |         MutableObjectIntMap<String> booleanMap = ObjectIntMaps.mutable.empty(); | ||||||
|  |         booleanMap.put("ok", 1); | ||||||
|  | 
 | ||||||
|  |         MutableIntIntMap mutableIntIntMap = IntIntMaps.mutable.empty(); | ||||||
|  |         mutableIntIntMap.addToValue(1, 1); | ||||||
|  | 
 | ||||||
|  |         ImmutableIntIntMap immutableIntIntMap = IntIntMaps.immutable.empty(); | ||||||
|  | 
 | ||||||
|  |         MutableObjectIntMap<String> intObject = ObjectIntMaps.mutable.empty(); | ||||||
|  |         intObject.addToValue("price", 2); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private static void troveMap() { | ||||||
|  | 
 | ||||||
|  |         double[] doubles = new double[] {1.2, 4.5, 0.3}; | ||||||
|  |         int[] ints = new int[] {1, 4, 0}; | ||||||
|  | 
 | ||||||
|  |         TDoubleIntMap doubleIntMap = new TDoubleIntHashMap(doubles, ints); | ||||||
|  | 
 | ||||||
|  |         doubleIntMap.adjustValue(1.2, 1); | ||||||
|  |         doubleIntMap.adjustValue(4.5, 4); | ||||||
|  |         doubleIntMap.adjustValue(0.3, 0); | ||||||
|  | 
 | ||||||
|  |         System.out.println(doubleIntMap); | ||||||
|  |     } | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user