对于放入HashMap在jsonobject中感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解hashmap存入元素的方法,并且为您提供关于gnu.trove.map.hash.TIntOb
对于放入HashMap 在jsonobject中感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解hashmap存入元素的方法,并且为您提供关于gnu.trove.map.hash.TIntObjectHashMap的实例源码、gnu.trove.map.hash.TLongObjectHashMap的实例源码、gnu.trove.map.hash.TObjectIntHashMap的实例源码、gnu.trove.map.hash.TObjectLongHashMap的实例源码的宝贵知识。
本文目录一览:- 放入HashMap 在jsonobject中(hashmap存入元素的方法)
- gnu.trove.map.hash.TIntObjectHashMap的实例源码
- gnu.trove.map.hash.TLongObjectHashMap的实例源码
- gnu.trove.map.hash.TObjectIntHashMap的实例源码
- gnu.trove.map.hash.TObjectLongHashMap的实例源码
放入HashMap 在jsonobject中(hashmap存入元素的方法)
我建立了一个由Hashmap中定义的nameValue对组成的json对象
我遇到的问题是当我调用时:
jsonObject.put(hashmap);
它像这样添加nameValue对:
name=value
代替 name:value
有什么想法吗?
谢谢
答案1
小编典典遍历HashMap并放入jsonObject:
Iterator it = mp.entrySet().iterator();while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); jsonObject.put(pairs.getKey(), pairs.getValue() );}
gnu.trove.map.hash.TIntObjectHashMap的实例源码
public void addPartition(EquivalenceManagedPartition partition) { if (!this.observedPartitions.contains(partition.getIndices()) && !this.containsSimilarPartition(partition)) { this.observedPartitions.add(partition.getIndices()); long hashNumber = partition.getHashNumber(); System.out.println(String.format("Partition[%s]\t%d\tSize: %d",partition.getIndices(),hashNumber,partition.size())); partitionHashes.putIfAbsent(hashNumber,new TIntObjectHashMap<THashSet<EquivalenceManagedPartition>>()); partitionHashes.get(hashNumber).putIfAbsent(partition.size(),new THashSet<EquivalenceManagedPartition>()); THashSet<EquivalenceManagedPartition> partitionGroup = partitionHashes.get(hashNumber).get(partition.size()); if (partitionGroup.isEmpty()) { partitionGroup.add(partition); } else { // then there is at least one element in the partitionGroup checkPossibleEquivalences(partitionGroup,partition); } } }
public CodeGenTypes(HIRModuleGenerator moduleBuilder,TargetData td) { builder = moduleBuilder; typeCaches = new HashMap<>(); recordBeingLaidOut = new HashSet<>(); functionBeingProcessed = new HashSet<>(); deferredRecords = new LinkedList<>(); recordDeclTypes = new HashMap<>(); cgRecordLayout = new HashMap<>(); fieldInfo = new HashMap<>(); bitfields = new HashMap<>(); context = moduleBuilder.getASTContext(); target = context.target; theModule = moduleBuilder.getModule(); targetData = td; pointersToResolve = new LinkedList<>(); tagDeclTypes = new HashMap<>(); functionTypes = new HashMap<>(); functionInfos = new TIntObjectHashMap<>(); }
public void register(Item item,int Meta,ModelResourceLocation location) { TIntObjectHashMap<ModelResourceLocation> locs = locations.get(item); TIntObjectHashMap<IBakedModel> mods = models.get(item); if (locs == null) { locs = new TIntObjectHashMap<ModelResourceLocation>(); locations.put(item,locs); } if (mods == null) { mods = new TIntObjectHashMap<IBakedModel>(); models.put(item,mods); } locs.put(Meta,location); mods.put(Meta,getModelManager().getModel(location)); }
public void createMesh(List<Mesher> meshers,JmeResourceManager resourceManager) { Realm realm = chunk.getRealm(); TIntObjectMap<Mesh> meshes = new TIntObjectHashMap<>(); for (Mesher mesher : meshers) { meshes.putAll(mesher.buildMeshes(chunk)); } geometries.clear(); for (int key : meshes.keys()) { Block block = realm.getCosmos().getBlocks().get(key); Geometry geometry = new Geometry(chunk.toString() + ":" + block.getName(),meshes.get(key)); geometry.setMaterial(resourceManager.getMaterial(block)); geometry.setQueueBucket(Bucket.Transparent); geometries.add(geometry); } }
public void testGet() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],vals[i]); } Map<Integer,String> map = TDecorators.wrap(raw_map); assertEquals(vals[10],map.get(Integer.valueOf(keys[10]))); assertNull(map.get(Integer.valueOf(1138))); Integer key = Integer.valueOf(1138); map.put(key,null); assertTrue(map.containsKey(key)); assertNull(map.get(key)); Long long_key = Long.valueOf(1138); //noinspection SuspicIoUsMethodCalls assertNull(map.get(long_key)); }
public void testContainsKey() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],String> map = TDecorators.wrap(raw_map); for (int i = 0; i < element_count; i++) { assertTrue("Key should be present: " + keys[i] + ",map: " + map,map.containsKey(keys[i])); } int key = 1138; assertFalse("Key should not be present: " + key + ",map.containsKey(key)); }
public void testContainsValue() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],String> map = TDecorators.wrap(raw_map); for (int i = 0; i < element_count; i++) { assertTrue("Value should be present: " + vals[i] + ",map.containsValue(vals[i])); } String val = "1138"; assertFalse("Key should not be present: " + val + ",map.containsValue(val)); //noinspection SuspicIoUsMethodCalls assertFalse("Random object should not be present in map: " + map,map.containsValue(new Object())); }
public void testPutAllMap() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_control = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_control.put(keys[i],String> control = TDecorators.wrap(raw_control); TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); Map<Integer,String> map = TDecorators.wrap(raw_map); Map<Integer,String> source = new HashMap<Integer,String>(); for (int i = 0; i < element_count; i++) { source.put(keys[i],vals[i]); } map.putAll(source); assertEquals(control,map); }
public void testPutAll() throws Exception { TIntObjectMap<String> raw_t = new TIntObjectHashMap<String>(); Map<Integer,String> t = TDecorators.wrap(raw_t); TIntObjectMap<String> raw_m = new TIntObjectHashMap<String>(); Map<Integer,String> m = TDecorators.wrap(raw_m); m.put(2,"one"); m.put(4,"two"); m.put(6,"three"); t.put(5,"four"); assertEquals(1,t.size()); t.putAll(m); assertEquals(4,t.size()); assertEquals("two",t.get(4)); }
public void testClear() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],String> map = TDecorators.wrap(raw_map); assertEquals(element_count,map.size()); map.clear(); assertTrue(map.isEmpty()); assertEquals(0,map.size()); assertNull(map.get(keys[5])); }
@SuppressWarnings({"unchecked"}) public void testSerialize() throws Exception { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],String> map = TDecorators.wrap(raw_map); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(map); ByteArrayInputStream bias = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bias); Map<Integer,String> deserialized = (Map<Integer,String>) ois.readobject(); assertEquals(map,deserialized); }
public void init(){ handlerMap = new HashMap<>(); TIntObjectHashMap<Class<?>> netEventHandlerClassMap = ServiceHelper.getNetEventListenerHandlerClassMap(); netEventHandlerClassMap.forEachEntry(new TIntObjectProcedure<Class<?>>() { @Override public boolean execute(int i,Class<?> aClass) { handlerMap.put(i,(NetEventListenerHandler) BeanHelper.getServiceBean(aClass)); return true; } }); selfAdd = Util.getHostAddress()+":"+Server.getEngineConfigure().getNetEventPort(); monitorService = BeanHelper.getServiceBean(MonitorService.class); eventService = BeanHelper.getServiceBean(EventService.class); monitorService.addStartCondition(SysConstantDefine.NetEventServiceStart,"wait for netEvent start and connect mainServer"); }
public DynamicGrid(T defaultElement,T[][] data){ this(defaultElement); for(int x = 0; x < data.length; ++x){ T[] arr = data[x]; TIntObjectHashMap<T> map = new TIntObjectHashMap<>(); for(int y = 0; y < arr.length; ++y){ T element = arr[y]; if(element != null){ map.put(y,element); } } map.compact(); grid.put(x,map); } grid.compact(); }
public void testContainsKey() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],map.containsKey(key)); }
public void testContainsValue() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],map.containsValue(new Object())); }
public void testPutAllMap() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_control = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_control.put(keys[i],map); }
public void testPutAll() throws Exception { TIntObjectMap<String> raw_t = new TIntObjectHashMap<String>(); Map<Integer,t.get(4)); }
public void testClear() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],map.size()); assertNull(map.get(keys[5])); }
@SuppressWarnings({"unchecked"}) public void testSerialize() throws Exception { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],deserialized); }
public static byte[] transform(WatchedEntity entity,byte[] data) throws IOException { if (entity == null) { return data; } TIntObjectMap<DataWatcherObject> objects = DataWatcherSerializer.decodeData(data); TIntObjectMap<DataWatcherObject> newobjects = new TIntObjectHashMap<DataWatcherObject>(); //copy entity moveDWData(objects,newobjects,0); //flags moveDWData(objects,1,1); //air moveDWData(objects,2,2); //naMetag moveDWData(objects,3,3); //naMetagvisible //copy specific types for (RemappingEntry entry : entity.getType().getRemaps()) { moveDWData(objects,entry.getFrom(),entry.getTo()); } return DataWatcherSerializer.encodeData(newobjects); }
public void setFeatureExtractor(TrendDetectorFeatureExtractor fe) { this.extractor = fe; final MersenneTwister rng = new MersenneTwister(); final DoubleGaussianFactory gauss = new DoubleGaussianFactory(fe.nDimensions(),rng,w); final HashFunctionFactory<double[]> factory = new HashFunctionFactory<double[]>() { @Override public HashFunction<double[]> create() { return new LSBModifier<double[]>(gauss.create()); } }; sketcher = new IntLSHSketcher<double[]>(factory,nbits); database = new ArrayList<TIntObjectHashMap<Set<WriteableImageOutput>>>( sketcher.arrayLength()); for (int i = 0; i < sketcher.arrayLength(); i++) database.add(new TIntObjectHashMap<Set<WriteableImageOutput>>()); }
private static TIntObjectMap<HostInfo> readHostInfos(String hostfile) { TIntObjectMap<HostInfo> hostMap = new TIntObjectHashMap<>(); try { int idx = 0; Scanner scanner = new Scanner(new FileReader(hostfile)); while (scanner.hasNext()) { String token = scanner.next(); String[] parts = token.trim().split(":"); Preconditions.checkArgument(parts.length == 2,"Malformed token in host file: %s",token); hostMap.put(idx,new HostInfo(idx,parts[0],parts[1])); idx++; } } catch (FileNotFoundException e) { e.printstacktrace(); System.exit(1); } return hostMap; }
public static void loadFileIndex(String file,TIntObjectHashMap<String> id_value){ try{ BufferedReader br = new BufferedReader(new FileReader(file)); String line = null; while((line=br.readLine()) != null){ String[] vals = line.split("\t"); id_value.put(Integer.parseInt(vals[0]),vals[1]+":"+vals[2]); } br.close(); } catch(Exception e){ e.printstacktrace(); } }
public static void loadindex(String file,vals[1]); } br.close(); } catch(Exception e){ e.printstacktrace(); } }
/** * Construct with the given parameters. * * @param minRad * minimum search radius * @param maxRad * maximum search radius * @param radIncrement * amount to increment search radius by between min and max. * @param nDegree * number of degree increments */ public HoughCircles(int minRad,int maxRad,int radIncrement,int nDegree) { super(); this.minRad = minRad; if (this.minRad <= 0) this.minRad = 1; this.maxRad = maxRad; this.radmap = new TIntObjectHashMap<TIntObjectHashMap<TIntFloatHashMap>>(); this.radIncr = radIncrement; this.nRadius = (maxRad - minRad) / this.radIncr; this.nDegree = nDegree; this.cosanglemap = new float[nRadius][nDegree]; this.sinanglemap = new float[nRadius][nDegree]; for (int radindex = 0; radindex < this.nRadius; radindex++) { for (int angIndex = 0; angIndex < nDegree; angIndex++) { final double ang = angIndex * (2 * PI / nDegree); final double rad = minRad + (radindex * this.radIncr); this.cosanglemap[radindex][angIndex] = (float) (rad * cos(ang)); this.sinanglemap[radindex][angIndex] = (float) (rad * sin(ang)); } } }
/** * Constuctor */ public ItemPathExtractorWorker(SynchronizedCounter counter,TObjectIntHashMap<String> path_index,TIntObjectHashMap<String> inverse_path_index,ItemTree main_item,ArrayList<ItemTree> items,TIntObjectHashMap<String> props_index,boolean inverseProps,TextFileManager textWriter,StringFileManager pathWriter,boolean select_top_path,TIntIntHashMap input_Metadata_id,boolean computeInversePaths,TIntObjectHashMap<TIntHashSet> items_link){ this.counter = counter; this.path_index = path_index; this.main_item = main_item; this.items = items; this.props_index = props_index; this.inverseProps = inverseProps; this.textWriter = textWriter; this.pathWriter = pathWriter; this.select_top_path = select_top_path; this.input_Metadata_id = input_Metadata_id; this.computeInversePaths = computeInversePaths; this.items_link = items_link; this.inverse_path_index = inverse_path_index; }
public Hashingtest() { final MersenneTwister rng = new MersenneTwister(); final DoubleGaussianFactory gauss = new DoubleGaussianFactory(ndims,nbits); database = new ArrayList<TIntObjectHashMap<Set<String>>>(sketcher.arrayLength()); for (int i = 0; i < sketcher.arrayLength(); i++) database.add(new TIntObjectHashMap<Set<String>>()); }
public JUnitCodeGenerator(final String cuName,final String packageName) { if(cuName == null || cuName.isEmpty()) { throw new IllegalArgumentException("Illegal compilation unit name: " + cuName); } if(packageName == null) { throw new NullPointerException("package name must not be null"); } this.packageName = packageName; this.cuName = cuName; this.oidToVarMapping = new TIntObjectHashMap<String>(); this.oidToTypeMapping = new TIntObjectHashMap<Class<?>>(); this.FailedRecords = new TIntHashSet(); this.init(); }
public CodeGenerator(final CaptureLog log) { if(log == null) { throw new NullPointerException(); } this.log = log.clone(); this.oidToVarMapping = new TIntObjectHashMap<String>(); this.oidToTypeMapping = new TIntObjectHashMap<Class<?>>(); this.varCounter = 0; this.isNewInstanceMethodNeeded = false; this.isCallMethodMethodNeeded = false; this.isSetFieldMethodNeeded = false; this.isGetFieldMethodNeeded = false; this.isXStreamNeeded = false; }
protected State (String name,int index,double initialWeight,double finalWeight,int[] inputs,int[] outputs,double[] weights,String[] destinationNames,FeatureTransducer transducer) { assert (inputs.length == outputs.length && inputs.length == weights.length && inputs.length == destinationNames.length); this.transducer = transducer; this.name = name; this.index = index; this.initialWeight = initialWeight; this.finalWeight = finalWeight; this.transitions = new Transition[inputs.length]; this.input2transitions = new TIntObjectHashMap(); transitionCounts = null; for (int i = 0; i < inputs.length; i++) { // This constructor places the transtion into this.input2transitions transitions[i] = new Transition (inputs[i],outputs[i],weights[i],this,destinationNames[i]); transitions[i].index = i; } }
public void testContainsKey() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],map.containsKey(key)); }
public void testContainsValue() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],map.containsValue(new Object())); }
public void testPutAllMap() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_control = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_control.put(keys[i],map); }
public void testPutAll() throws Exception { TIntObjectMap<String> raw_t = new TIntObjectHashMap<String>(); Map<Integer,t.get(4)); }
public void testClear() { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],map.size()); assertNull(map.get(keys[5])); }
@SuppressWarnings({"unchecked"}) public void testSerialize() throws Exception { int element_count = 20; int[] keys = new int[element_count]; String[] vals = new String[element_count]; TIntObjectMap<String> raw_map = new TIntObjectHashMap<String>(); for (int i = 0; i < element_count; i++) { keys[i] = i + 1; vals[i] = Integer.toString(i + 1); raw_map.put(keys[i],deserialized); }
protected void initForgraph (Factorgraph m) { super.initForgraph (m); int numNodes = m.numVariables (); factorTouched = new TIntObjectHashMap (numNodes); hasConverged = false; if (factory == null) { factory = new AlmostRandomTreeFactory (); } if (terminator == null) { terminator = new DefaultConvergenceTerminator (); } else { terminator.reset (); } }
public LLParser(MemoryBuffer buf,SourceMgr smg,Module m,OutParamWrapper<SMDiagnostic> diag) { lexer = new LLLexer(buf,smg,diag); this.m = m; forwardRefTypes = new TreeMap<>(); forwardRefTypeIDs = new TIntObjectHashMap<>(); numberedTypes = new ArrayList<>(); MetadataCache = new TIntObjectHashMap<>(); forwardRefMDNodes = new TIntObjectHashMap<>(); upRefs = new ArrayList<>(); forwardRefVals = new TreeMap<>(); forwardRefValIDs = new TIntObjectHashMap<>(); numberedVals = new ArrayList<>(); }
/** * Constructor * @param type the type for this array * @param length the length for this array * @param defaultValue the default value */ SparseArrayOfObjects(Class<T> type,int length,T defaultValue) { super(type,ArrayStyle.SPARSE,false); this.length = length; this.defaultValue = defaultValue; this.values = new TIntObjectHashMap<>((int)Math.max(length * 0.5,10d),0.8f,-1); }
public void rebuildCache() { final ModelManager manager = this.getModelManager(); for (Map.Entry<Item,TIntObjectHashMap<ModelResourceLocation>> e : locations.entrySet()) { TIntObjectHashMap<IBakedModel> mods = models.get(e.getKey()); if (mods != null) { mods.clear(); } else { mods = new TIntObjectHashMap<IBakedModel>(); models.put(e.getKey(),mods); } final TIntObjectHashMap<IBakedModel> map = mods; e.getValue().forEachEntry(new TIntObjectProcedure<ModelResourceLocation>() { @Override public boolean execute(int Meta,ModelResourceLocation location) { map.put(Meta,manager.getModel(location)); return true; } }); } }
gnu.trove.map.hash.TLongObjectHashMap的实例源码
private void disturb(long pos,BlockState blockState,@Nullable ParticipantState disturber) { FallingBlocksRule rule = this.ruleWithShortestDelay(blockState); if(rule != null) { long tick = this.getmatch().getClock().Now().tick + rule.delay; TLongObjectMap<ParticipantState> blockdisturbers = this.blockdisturbersByTick.get(tick); if(blockdisturbers == null) { blockdisturbers = new TLongObjectHashMap<>(); this.blockdisturbersByTick.put(tick,blockdisturbers); } Block block = blockState.getBlock(); if(!blockdisturbers.containsKey(pos)) { blockdisturbers.put(pos,disturber); } } }
@Override public void calculateallReduceFactors(final TLongObjectMap<TLongArrayList> nodeSegmentTable,final TLongObjectMap<ISegment> segmentsTable,final TLongSet relevantLinks,TLongObjectMap<IPixelCut> pixelCuts) { TLongObjectMap<IRenderingSegment> renderingResults = new TLongObjectHashMap<>(); nodeSegmentTable.forEachEntry((nodeId,segmentIds) -> { if (segmentIds.size() > 1) { ISegment[] segments = new ISegment[segmentIds.size()]; for (int i = 0; i < segmentIds.size(); i++) { segments[i] = segmentsTable.get(segmentIds.get(i)); } investigateNode(nodeId,renderingResults,segments); } return true; }); adaptPixelCuts(pixelCuts,renderingResults); }
public WaySink(TLongObjectHashMap<List<WayRef>> wayRefs,TLongObjectHashMap<NodeCoord> nodes,TLongObjectHashMap<List<IWaySegment>> segmentedWaySegments,TLongObjectHashMap<List<Relation>> wayRelations,BlockingQueue<IWaySegment> waysQueue) { this.wayRefs = wayRefs; this.nodes = nodes; this.wayRelations = wayRelations; this.segmentedWaySegments = segmentedWaySegments; for (long nodeId : wayRefs.keys()) { List<WayRef> wayRefList = wayRefs.get(nodeId); for (WayRef wayRef : wayRefList) { if (wayRef.getType() == 2) { if (waysToSegment.get(wayRef.getWayId()) == null) { waysToSegment.put(wayRef.getWayId(),new TLongArrayList(new long[] {nodeId})); } else { waysToSegment.get(wayRef.getWayId()).add(nodeId); } } } } this.waysQueue = waysQueue; this.connectionsBuilder = new ConnectionsBuilder(); }
public SegmentationWaySink(TLongObjectHashMap<List<WayRef>> wayRefs,BlockingQueue<IWaySegment> waysQueue) { this.wayRefs = wayRefs; this.wayRelations = wayRelations; for (long nodeId : wayRefs.keys()) { List<WayRef> wayRefList = wayRefs.get(nodeId); for (WayRef wayRef : wayRefList) { if (wayRef.getType() == 2) { if (waysToSegment.get(wayRef.getWayId()) == null) { waysToSegment.put(wayRef.getWayId(),new TLongArrayList(new long[] {nodeId})); } else { waysToSegment.get(wayRef.getWayId()).add(nodeId); } } } } this.waysQueue = waysQueue; connectionsBuilder = new ConnectionsBuilder(); }
@Override public void update(JSONObject json) { position = json.optInt("position"); if(overwrites == null) overwrites = new TLongObjectHashMap<>(); TLongSet toRemove = new TLongHashSet(overwrites.keys()); JSONArray array = json.getJSONArray("permission_overwrites"); for(int i = 0,j = array.length(); i < j; i++) { JSONObject overwrite = array.getJSONObject(i); long id = overwrite.getLong("id"); toRemove.remove(id); overwrites.put(id,new CachedOverwrite(overwrite)); } for(TLongIterator it = toRemove.iterator(); it.hasNext();) { overwrites.remove(it.next()); } name = json.optString("name"); topic = json.optString("topic"); nsfw = json.optBoolean("nsfw"); lastMessageId = json.optLong("last_message_id"); bitrate = json.optInt("bitrate"); userLimit = json.optInt("user_limit"); parentId = json.optLong("parent_id"); }
/** * Returns all quads in this tree recombined as much as possible. * Use instead of allRawQuads() for anything to be rendered. * Generally only useful on job node! * * Will only work if build was called with initCSG parameter = true * during initialization of the tree because it uses the information populated then. * @return */ public List<RawQuad> recombinedRawQuads() { TLongObjectHashMap<ArrayList<RawQuad>> ancestorBuckets = new TLongObjectHashMap<ArrayList<RawQuad>>(); this.allRawQuads().forEach((quad) -> { if(!ancestorBuckets.contains(quad.ancestorQuadID)) { ancestorBuckets.put(quad.ancestorQuadID,new ArrayList<RawQuad>()); } ancestorBuckets.get(quad.ancestorQuadID).add(quad); }); ArrayList<RawQuad> retVal = new ArrayList<RawQuad>(); ancestorBuckets.valueCollection().forEach((quadList) -> { retVal.addAll(recombine(quadList)); }); return retVal; }
public static TLongObjectHashMap loadLong2TXTGZMap(String mapFile,boolean reverse) throws IOException { long time = System.currentTimeMillis(); TLongObjectHashMap idMap = new TLongObjectHashMap(); BufferedReader br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(mapFile)))); String line; String[] parts; while ((line = br.readLine()) != null) { parts = line.split(SEP); if (!reverse) { idMap.put(Long.parseLong(parts[0]),parts[1]); } else { idMap.put(Long.parseLong(parts[1]),parts[0]); } } logger.info(((System.currentTimeMillis() - time) / 1000d) + "s"); return idMap; }
private HDTileBasedDataProcessor(MapWriterConfiguration configuration) { super(configuration); this.indexednodeStore = new IndexedobjectStore<Node>(new SingleClassObjectSerializationFactory(Node.class),"idxNodes"); this.indexedWayStore = new IndexedobjectStore<Way>(new SingleClassObjectSerializationFactory(Way.class),"idxWays"); // indexedRelationStore = new IndexedobjectStore<Relation>( // new SingleClassObjectSerializationFactory( // Relation.class),"idxWays"); this.wayStore = new SimpleObjectStore<Way>(new SingleClassObjectSerializationFactory(Way.class),"heapWays",true); this.relationStore = new SimpleObjectStore<Relation>(new SingleClassObjectSerializationFactory(Relation.class),"heapRelations",true); this.tileData = new HDTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][]; for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) { this.tileData[i] = new HDTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i] .getAmountTilesvertical()]; } this.virtualWays = new TLongObjectHashMap<TDWay>(); this.additionalRelationTags = new TLongObjectHashMap<List<TDRelation>>(); }
/** * * @see org.jmangos.commons.dataholder.DataLoadService#load() */ @Override public TLongObjectHashMap<ItemPrototype> load() { Long eTime = System.currentTimeMillis(); final TLongObjectHashMap<ItemPrototype> map = new TLongObjectHashMap<ItemPrototype>(); final List<ItemPrototype> itemPrototypeList = this.itemPrototypeService.readItemPrototypes(); // Fill map for (final ItemPrototype item : itemPrototypeList) { map.put(item.getEntry(),item); } eTime = System.currentTimeMillis() - eTime; ItemStorages.logger.info(String.format("Loaded [%d] ItemPrototypes under %d ms",map.size(),eTime)); this.itemPrototypes = map; return this.itemPrototypes; }
/** * Make any unsupported blocks fall that are disturbed for the current tick */ private void fallCheck() { this.visitsWorstTick = Math.max(this.visitsWorstTick,this.visitsThisTick); this.visitsThisTick = 0; World world = this.getmatch().getWorld(); TLongObjectMap<ParticipantState> blockdisturbers = this.blockdisturbersByTick.remove(this.getmatch().getClock().Now().tick); if(blockdisturbers == null) return; TLongSet supported = new TLongHashSet(); TLongSet unsupported = new TLongHashSet(); TLongObjectMap<ParticipantState> fallsByBreaker = new TLongObjectHashMap<>(); try { while(!blockdisturbers.isEmpty()) { long pos = blockdisturbers.keySet().iterator().next(); ParticipantState breaker = blockdisturbers.remove(pos); // Search down for the first block that can actually fall for(;;) { long below = neighborPos(pos,BlockFace.DOWN); if(!Materials.isColliding(blockAt(world,below).getType())) break; blockdisturbers.remove(pos); // Remove all the blocks we find along the way pos = below; } // Check if the block needs to fall,if it isn't already falling if(!fallsByBreaker.containsKey(pos) && !this.isSupported(pos,supported,unsupported)) { fallsByBreaker.put(pos,breaker); } } } catch(MaxSearchVisitsExceeded ex) { this.logError(ex); } for(TLongObjectIterator<ParticipantState> iter = fallsByBreaker.iterator(); iter.hasNext();) { iter.advance(); this.fall(iter.key(),iter.value()); } }
public RelationSink(TLongObjectHashMap<List<WayRef>> wayRefs) { for (List<WayRef> wayRefList : wayRefs.valueCollection()) { for (WayRef wayRef : wayRefList) { wayIds.add(wayRef.getWayId()); } } }
public GipLinkSectionParser(IGipParser parserReference,IGipSectionParser<TLongObjectMap<IGipNode>> nodeParser,IImportConfig config,ImportStatistics statistics) { super(parserReference); this.links = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>()); this.nodeParser = nodeParser; this.functionalRoadClasses = config.getFrcList(); this.accesstypes = config.getAccesstypes(); this.executor = Executors.newFixedThreadPool(15); this.statistics = statistics; }
private TLongObjectMap<IPixelCut> calculatePixelCutOffset(IImportConfig config,TLongSet linkIdsEnqueued,TLongObjectMap<IGipLink> links){ log.info("phase pixel cut calculation ...."); TLongObjectMap<IPixelCut> renderingResultPerSegment = new TLongObjectHashMap<>(); final TLongObjectHashMap<TLongArrayList> nodeLinksConnectionTable = new TLongObjectHashMap<>(); log.info("Link Ids Queued size: " + linkIdsEnqueued.size()); GipLinkFilter filter = new GipLinkFilter(config.getMaxFrc(),config.getMinFrc(),config.getIncludedGipIds(),config.getExcludedGipIds(),config.isEnableSmallConnections()); TLongSet filteredLinks = filter.filter(links); linkIdsEnqueued.forEach(value -> { //enqued Gip Links that after they have been filtered. if (filteredLinks.contains(value)) { IGipLink link = links.get(value); if (link != null) { if (link.getFromNodeId() != 0) { if (!nodeLinksConnectionTable.containsKey(link.getFromNodeId())) { nodeLinksConnectionTable.put(link.getFromNodeId(),new TLongArrayList()); } nodeLinksConnectionTable.get(link.getFromNodeId()).add(link.getId()); } if (link.getToNodeId() != 0) { if (!nodeLinksConnectionTable.containsKey(link.getToNodeId())) { nodeLinksConnectionTable.put(link.getToNodeId(),new TLongArrayList()); } nodeLinksConnectionTable.get(link.getToNodeId()).add(link.getId()); } } } return true; }); log.info("Filtered Links Size " + filteredLinks.size()); renderingResultPerSegment = new TLongObjectHashMap<>(); IRenderingCalculator renderingCalculator = new RenderingCalculatorImpl(); renderingCalculator.calculateallReduceFactors(nodeLinksConnectionTable,adaptSegments(links),filteredLinks,renderingResultPerSegment); log.info("Rendering result size " + renderingResultPerSegment.size()); return renderingResultPerSegment; }
private TLongObjectMap<ISegment> adaptSegments(TLongObjectMap<IGipLink> links) { TLongObjectMap<ISegment> segments = new TLongObjectHashMap<>(links.size()); for (Long id : links.keys()) { IGipLink link = links.get(id); segments.put(id,new SegmentImpl(link.getId(),link.getFromNodeId(),link.getToNodeId(),link.getCoordinatesX(),link.getCoordinatesY(),link.getFuncRoadClassValue())); } return segments; }
public GipLinkTurnEdgesParser(IGipParser parserReference,IGipSectionParser<TLongObjectMap<IGipLink>> linkParser,IGipSectionParser<TLongSet> linkCoordinateParser) { super(parserReference); this.config = config; this.nodeParser = nodeParser; this.linkParser = linkParser; this.linkCoordinateParser = linkCoordinateParser; this.turnEdges = new TLongObjectHashMap<>(); }
@Benchmark public void manualSnchronizedTLongObjectHashMapGet(Context context) { TLongObjectHashMap<Object> map = new TLongObjectHashMap<>(); synchronized (map) { troveMapGet(context,map); } }
@Benchmark public void manualSnchronizedTLongObjectHashMapUpdate(Context context) { TLongObjectHashMap<Object> map = new TLongObjectHashMap<>(); synchronized (map) { troveMapPutUpdate(context,map); } }
@Benchmark public void manualSnchronizedTLongObjectHashMapPutRemove(Context context) { TLongObjectHashMap<Object> map = new TLongObjectHashMap<>(); synchronized (map) { troveMapPutRemove(context,map); } }
@Benchmark public TLongObjectHashMap manualSnchronizedTLongObjectHashMapMapcopy(Context context) { TLongObjectHashMap<Object> map = new TLongObjectHashMap<>(); synchronized (map) { //Populate the map the first time for (int i = 0; i < context.testValues.length; i++) map.put(context.testKeys[i],context.testValues[i]); //copy! TLongObjectHashMap<Object> copy = new TLongObjectHashMap<>(map); return copy; } }
@Benchmark public void synchronizedTLongObjectHashMapGet(Context context) { TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>()); synchronized (map) { troveMapGet(context,map); } }
@Benchmark public void synchronizedTLongObjectHashMapUpdate(Context context) { TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>()); synchronized (map) { troveMapPutUpdate(context,map); } }
@Benchmark public void synchronizedTLongObjectHashMapPutRemove(Context context) { TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>()); synchronized (map) { troveMapPutRemove(context,map); } }
@Benchmark public TSynchronizedLongObjectMap synchronizedTLongObjectHashMapMapcopy(Context context) { TSynchronizedLongObjectMap<Object> map = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>()); synchronized (map) { //Populate the map the first time for (int i = 0; i < context.testValues.length; i++) map.put(context.testKeys[i],context.testValues[i]); //copy! TSynchronizedLongObjectMap<Object> copy = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>(map)); return copy; } }
public static synchronized void initialize(EntityManager em) { TLongObjectHashMap<Currency> currencies = new TLongObjectHashMap<Currency>(); Query<Currency> q = em.createquery(Currency.class); Cursor c = q.execute(); try { while (c.movetoNext()) { Currency currency = EntityManager.loadFromCursor(c,Currency.class); currencies.put(currency.id,currency); } } finally { c.close(); } CURRENCIES.putAll(currencies); }
private TLongObjectMap<ExchangeRate> getMapFor(long fromCurrencyId) { TLongObjectMap<ExchangeRate> m = rates.get(fromCurrencyId); if (m == null) { m = new TLongObjectHashMap<ExchangeRate>(); rates.put(fromCurrencyId,m); } return m; }
private TLongObjectMap<SortedSet<ExchangeRate>> getMapFor(long fromCurrencyId) { TLongObjectMap<SortedSet<ExchangeRate>> m = rates.get(fromCurrencyId); if (m == null) { m = new TLongObjectHashMap<SortedSet<ExchangeRate>>(); rates.put(fromCurrencyId,m); } return m; }
public TLongObjectMap<GuildMusicPlayer> getPlayers() { TLongObjectMap<GuildMusicPlayer> map = new TLongObjectHashMap<>(); for(Shard s : shards) { map.putAll(s.players()); } return map; }
public static synchronized void initialize(EntityManager em) { TLongObjectHashMap<Currency> currencies = new TLongObjectHashMap<Currency>(); Query<Currency> q = em.createquery(Currency.class); Cursor c = q.execute(); try { while (c.movetoNext()) { Currency currency = EntityManager.loadFromCursor(c,currency); } } finally { c.close(); } CURRENCIES.putAll(currencies); }
private TLongObjectMap<ExchangeRate> getMapFor(long fromCurrencyId) { TLongObjectMap<ExchangeRate> m = rates.get(fromCurrencyId); if (m == null) { m = new TLongObjectHashMap<>(); rates.put(fromCurrencyId,m); } return m; }
private TLongObjectMap<SortedSet<ExchangeRate>> getMapFor(long fromCurrencyId) { TLongObjectMap<SortedSet<ExchangeRate>> m = rates.get(fromCurrencyId); if (m == null) { m = new TLongObjectHashMap<>(); rates.put(fromCurrencyId,m); } return m; }
public void cache(Type type,long triggerId,Runnable handler) { TLongObjectMap<List<Runnable>> triggerCache = eventCache.computeIfAbsent(type,k -> new TLongObjectHashMap<>()); List<Runnable> items = triggerCache.get(triggerId); if (items == null) { items = new LinkedList<>(); triggerCache.put(triggerId,items); } items.add(handler); }
/** * Constructs an unavailable Widget */ private Widget(long guildId) { isAvailable = false; id = guildId; name = null; invite = null; channels = new TLongObjectHashMap<>(); members = new TLongObjectHashMap<>(); }
private CB_RAMTileBasedDataProcessor(CB_MapWriterConfiguration configuration) { super(configuration); this.nodes = new TLongObjectHashMap<>(); this.ways = new TLongObjectHashMap<>(); this.multipolygons = new TLongObjectHashMap<>(); this.tileData = new CB_RAMTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][]; // compute number of tiles needed on each base zoom level for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) { this.tileData[i] = new CB_RAMTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i] .getAmountTilesvertical()]; } }
public CB_BaseTileBasedDataProcessor(CB_MapWriterConfiguration configuration) { super(); this.boundingBox = configuration.getBBoxConfiguration(); this.zoomIntervalConfiguration = configuration.getZoomIntervalConfiguration(); this.tileGridLayouts = new TileGridLayout[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()]; this.bBoxEnlargement = configuration.getBBoxEnlargement(); this.preferredLanguages = configuration.getPreferredLanguages(); this.skipInvalidRelations = configuration.isSkipInvalidRelations(); this.outerToInnerMapping = new TLongObjectHashMap<>(); this.innerWaysWithoutAdditionalTags = new TLongHashSet(); this.tilesToCoastlines = new HashMap<>(); this.countWays = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()]; this.countWayTileFactor = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()]; this.histogramPoiTags = new TShortIntHashMap(); this.histogramWayTags = new TShortIntHashMap(); // compute horizontal and vertical tile coordinate offsets for all // base zoom levels for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) { TileCoordinate upperLeft = new TileCoordinate((int) MercatorProjection.longitudetoTileX( this.boundingBox.minLongitude,this.zoomIntervalConfiguration.getBaseZoom(i)),(int) MercatorProjection.latitudetoTileY(this.boundingBox.maxLatitude,this.zoomIntervalConfiguration.getBaseZoom(i)); this.tileGridLayouts[i] = new TileGridLayout(upperLeft,computeNumberOfHorizontalTiles(i),computeNumberOfVerticalTiles(i)); } }
public boolean aggregate() { if (size == 0) return false; boolean aggregated = false; //HashMap<Long,MatrixEntry> table = new HashMap<Long,MatrixEntry>(); TLongObjectHashMap<Entry> table = new TLongObjectHashMap<Entry>(); for (int i = 0; i < size; ++i) { int id = x[i]; Entry item = table.get(id); if (item != null) { item.value += va[i]; aggregated = true; } else table.put(id,new Entry(id,va[i])); } if (!aggregated) return false; int p = 0; for (Entry e : table.valueCollection()) { if (e.value != 0) { x[p] = e.x; va[p] = e.value; ++p; } } size = p; return true; }
public List<IShape> createSplitRoad(final Way way,final Map<String,Object> values,final TLongHashSet intersectionNodes,final TLongObjectHashMap<GamaShape> nodesPt) { final List<List<IShape>> pointsList = GamaListFactory.create(Types.LIST.of(Types.GEOMETRY)); List<IShape> points = GamaListFactory.create(Types.GEOMETRY); final IList<IShape> geometries = GamaListFactory.create(Types.GEOMETRY); final WayNode endNode = way.getWayNodes().get(way.getWayNodes().size() - 1); for (final WayNode node : way.getWayNodes()) { final Long id = node.getNodeId(); final GamaShape pt = nodesPt.get(id); if (pt == null) { continue; } points.add(pt); if (intersectionNodes.contains(id) || node == endNode) { if (points.size() > 1) { pointsList.add(points); } points = GamaListFactory.create(Types.GEOMETRY); points.add(pt); } } for (final List<IShape> pts : pointsList) { final IShape g = createRoad(pts,values); if (g != null) { geometries.add(g); } } return geometries; }
/** * Constructs a TempFileCache which creates temporary files in the directory specified. * If the file is null,then temporary files will be created in the default temp directory. * * @param tempDir The directory to create temporary files in. * @throws java.lang.IllegalArgumentException if the tempdir supplied is not a directory. */ public TempFileCache(final File tempDir) { windowPositions = new TLongObjectHashMap<WindowInfo>(); this.tempDir = tempDir; if (tempDir != null && !tempDir.isDirectory()) { throw new IllegalArgumentException("The temp dir file supplied is not a directory: " + tempDir.getAbsolutePath()); } }
public TopAndTailStreamCache(final long topBytes,final long tailBytes) { this.topCacheBytes = topBytes; this.tailCacheBytes = tailBytes; cache = new TLongObjectHashMap<Window>(); tailEntries = new ArrayList<Window>(); }
public BaseTileBasedDataProcessor(MapWriterConfiguration configuration) { super(); this.boundingBox = configuration.getBBoxConfiguration(); this.zoomIntervalConfiguration = configuration.getZoomIntervalConfiguration(); this.tileGridLayouts = new TileGridLayout[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()]; this.bBoxEnlargement = configuration.getBBoxEnlargement(); this.preferredLanguage = configuration.getPreferredLanguage(); this.skipInvalidRelations = configuration.isSkipInvalidRelations(); this.outerToInnerMapping = new TLongObjectHashMap<TLongArrayList>(); this.innerWaysWithoutAdditionalTags = new TLongHashSet(); this.tilesToCoastlines = new HashMap<TileCoordinate,TLongHashSet>(); this.countWays = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()]; this.countWayTileFactor = new float[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()]; this.histogramPoiTags = new TShortIntHashMap(); this.histogramWayTags = new TShortIntHashMap(); // compute horizontal and vertical tile coordinate offsets for all // base zoom levels for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) { TileCoordinate upperLeft = new TileCoordinate((int) MercatorProjection.longitudetoTileX( this.boundingBox.minLongitude,computeNumberOfVerticalTiles(i)); } }
private RAMTileBasedDataProcessor(MapWriterConfiguration configuration) { super(configuration); this.nodes = new TLongObjectHashMap<TDNode>(); this.ways = new TLongObjectHashMap<TDWay>(); this.multipolygons = new TLongObjectHashMap<TDRelation>(); this.tileData = new RAMTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][]; // compute number of tiles needed on each base zoom level for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) { this.tileData[i] = new RAMTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i] .getAmountTilesvertical()]; } }
gnu.trove.map.hash.TObjectIntHashMap的实例源码
private static TObjectIntMap<String> buildAccessors(int accessFlags) { TObjectIntMap<String> map = new TObjectIntHashMap<>(); map.put("public",Modifier.isPublic(accessFlags) ? 1 : 0); map.put("protected",Modifier.isProtected(accessFlags) ? 1 : 0); map.put("private",Modifier.isPrivate(accessFlags) ? 1 : 0); map.put("final",Modifier.isFinal(accessFlags) ? 1 : 0); map.put("interface",Modifier.isInterface(accessFlags) ? 1 : 0); map.put("native",Modifier.isNative(accessFlags) ? 1 : 0); map.put("static",Modifier.isstatic(accessFlags) ? 1 : 0); map.put("strict",Modifier.isstrict(accessFlags) ? 1 : 0); map.put("synchronized",Modifier.isSynchronized(accessFlags) ? 1 : 0); map.put("transient",Modifier.isTransient(accessFlags) ? 1 : 0); map.put("volatile",Modifier.isVolatile(accessFlags) ? 1 : 0); map.put("abstract",Modifier.isAbstract(accessFlags) ? 1 : 0); return map; }
private static TObjectIntMap<String> buildAccessors(int accessFlags) { TObjectIntMap<String> map = new TObjectIntHashMap<>(); map.put("public",Modifier.isAbstract(accessFlags) ? 1 : 0); return map; }
/** * Gathers and enumerates all the itinerary classes. * Returns itinerary class count. * @param os * @param itinClassesMap * @return */ private int collectAllItinClasses(PrintStream os,TObjectIntHashMap<String> itinClassesMap) throws Exception { ArrayList<Record> itinClassList = records.getAllDerivedDeFinition("InstrItinClass"); itinClassList.sort(LessRecord); // for each itinenary class. int n = itinClassList.size(); for (int i = 0; i < n; i++) { Record itinClass = itinClassList.get(i); itinClassesMap.put(itinClass.getName(),i); } return n; }
/** * Emits all stages and itineries,folding common patterns. * @param os */ private void emitData(PrintStream os) throws Exception { TObjectIntHashMap<String> itinClassesMap = new TObjectIntHashMap<>(); ArrayList<ArrayList<InstrItinerary>> procList = new ArrayList<>(); // Enumerate all the itinerary classes int nitinCLasses = collectAllItinClasses(os,itinClassesMap); // Make sure the rest is worth the effort hasItrineraries = nitinCLasses != 1; if (hasItrineraries) { // Emit the stage data emitStageAndOperandCycleData(os,nitinCLasses,itinClassesMap,procList); // Emit the processor itinerary data emitProcessorData(os,procList); // Emit the processor lookup data emitProcessorLookup(os); } }
private void findDepVarsOf(TreePatternNode node,TObjectIntHashMap<String> depMap) { if (node.isLeaf()) { if (node.getLeafValue() instanceof DefInit) { if (depMap.containsKey(node.getName())) depMap.put(node.getName(),depMap.get(node.getName()) + 1); else depMap.put(node.getName(),1); } } else { for (int i = 0,e = node.getNumChildren(); i != e; i++) findDepVarsOf(node.getChild(i),depMap); } }
public PromoteMemToReg(ArrayList<AllocaInst> allocas,DomTree dt,DominanceFrontier df,AliasSetTracker ast) { this.allocas = allocas; this.dt = dt; this.df = df; this.ast = ast; allocaLookup = new TObjectIntHashMap<>(); newPhiNodes = new HashMap<>(); visitedBlocks = new HashSet<>(); bbNumbers = new TObjectIntHashMap<>(); phiToAllocaMap = new TObjectIntHashMap<>(); pointerallocaValues = new ArrayList<>(); }
/** * This method must be overridded by concrete subclass for performing * desired machine code transformation or analysis. * * @param mf * @return */ @Override public boolean runOnMachineFunction(MachineFunction mf) { this.mf = mf; tm = mf.getTarget(); regInfo = tm.getRegisterInfo(); instrInfo = tm.getInstrInfo(); stackSlotForVirReg = new TIntIntHashMap(); regUsed = new BitMap(); regClassIdx = new TObjectIntHashMap<>(); for (MachineBasicBlock mbb : mf.getBasicBlocks()) allocateBasicBlock(mbb); stackSlotForVirReg.clear(); return true; }
public void testGetMap() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; raw_map.put( keys[i],vals[i] ); } //noinspection MismatchedQueryAndUpdateOfCollection TObjectIntMapDecorator<String> map = new TObjectIntMapDecorator<String>( raw_map ); assertEquals( raw_map,map.getMap() ); }
public void testContainsKey() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> map = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; map.put( keys[i],vals[i] ); } for ( int i = 0; i < element_count; i++ ) { assertTrue( "Key should be present: " + keys[i] + ",map: " + map,map.containsKey( keys[i] ) ); } String key = "1138"; assertFalse( "Key should not be present: " + key + ",map.containsKey( key ) ); assertFalse( "Random object should not be present in map: " + map,map.containsKey( new Object() ) ); }
public void testContainsValue() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> map = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; map.put( keys[i],vals[i] ); } for ( int i = 0; i < element_count; i++ ) { assertTrue( "Value should be present: " + vals[i] + ",map.containsValue( vals[i] ) ); } int val = 1138; assertFalse( "Key should not be present: " + val + ",map.containsValue( val ) ); }
public void testPutAllMap() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> control = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; control.put( keys[i],vals[i] ); } TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>(); Map<String,Integer> map = TDecorators.wrap( raw_map ); Map<String,Integer> source = new HashMap<String,Integer>(); for ( int i = 0; i < element_count; i++ ) { source.put( keys[i],vals[i] ); } map.putAll( source ); assertEquals( source,map ); assertEquals( control,raw_map ); }
public void testClear() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>(); Map<String,Integer> map = TDecorators.wrap( raw_map ); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; map.put( keys[i],vals[i] ); } assertEquals( element_count,raw_map.size() ); map.clear(); assertTrue( map.isEmpty() ); assertEquals( 0,map.size() ); assertNull( map.get( keys[5] ) ); }
public void testValues() { int element_count = 20; String[] keys = new String[element_count]; Integer[] vals = new Integer[element_count]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>( element_count,0.5f,Integer.MIN_VALUE ); Map<String,Integer> map = TDecorators.wrap( raw_map ); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = Integer.valueOf( i + 1 ); map.put( keys[i],map.size() ); // No argument Collection<Integer> values_collection = map.values(); assertEquals( element_count,values_collection.size() ); List<Integer> values_list = new ArrayList<Integer>( values_collection ); for ( int i = 0; i < element_count; i++ ) { assertTrue( values_list.contains( vals[i] ) ); } }
@SuppressWarnings({"unchecked"}) public void testSerialize() throws Exception { Integer[] vals = {1138,42,86,99,101,727,117}; String[] keys = new String[vals.length]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>(); Map<String,Integer> map = TDecorators.wrap( raw_map ); for ( int i = 0; i < keys.length; i++ ) { keys[i] = Integer.toString( vals[i] * 2 ); map.put( keys[i],vals[i] ); } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream( baos ); oos.writeObject( map ); ByteArrayInputStream bias = new ByteArrayInputStream( baos.toByteArray() ); ObjectInputStream ois = new ObjectInputStream( bias ); Map<String,Integer> deserialized = ( Map<String,Integer> ) ois.readobject(); assertEquals( map,deserialized ); }
@SubscribeEvent(priority = EventPriority.LOW) public void diagnostics(final DiagnosticEvent.Gather event) { final TObjectIntHashMap<String> counts = new TObjectIntHashMap<String>(); final Iterator<Entry<String,ISound>> iterator = this.playingSounds.entrySet().iterator(); while (iterator.hasNext()) { Entry<String,ISound> entry = iterator.next(); ISound isound = entry.getValue(); counts.adjustOrPutValue(isound.getSound().getSoundLocation().toString(),1,1); } final ArrayList<String> results = new ArrayList<String>(); final TObjectIntIterator<String> itr = counts.iterator(); while (itr.hasNext()) { itr.advance(); results.add(String.format(textformatting.GOLD + "%s: %d",itr.key(),itr.value())); } Collections.sort(results); event.output.addAll(results); }
/** * This method represents the last step that's executed when processing a query. A list of partial-results (distanceElements) returned by * the lookup stage is processed based on some internal method and finally converted to a list of scoreElements. The filtered list of * scoreElements is returned by the feature module during retrieval. * * @param partialResults List of partial results returned by the lookup stage. * @param qc A ReadableQueryConfig object that contains query-related configuration parameters. * @return List of final results. Is supposed to be de-duplicated and the number of items should not exceed the number of items per module. */ @Override protected List<scoreElement> postprocessQuery(List<SegmentdistanceElement> partialResults,ReadableQueryConfig qc) { /* Prepare helper data-structures. */ final List<scoreElement> results = new ArrayList<>(); final TObjectIntHashMap<String> scoreMap = new TObjectIntHashMap<>(); /* Set QueryConfig and extract correspondence function. */ qc = this.setQueryConfig(qc); final CorrespondenceFunction correspondence = qc.getCorrespondenceFunction().orElse(this.linearCorrespondence); for (distanceElement hit : partialResults) { if (hit.getdistance() < this.distanceThreshold) { scoreMap.adjustOrPutValue(hit.getId(),scoreMap.get(hit.getId())/2); } } /* Prepare final result-set. */ scoreMap.forEachEntry((key,value) -> results.add(new SegmentscoreElement(key,1.0 - 1.0/value))); scoreElement.filterMaximumscores(results.stream()); return results; }
@Override public void addDocument(Document doc) throws IOException { // add the document lengths.get(document).add(doc.identifier,doc.terms.size()); // Now deal with fields: TObjectIntHashMap<Bytes> currentFieldLengths = new TObjectIntHashMap<>(doc.tags.size()); for (Tag tag : doc.tags) { int len = tag.end - tag.begin; currentFieldLengths.adjustOrPutValue(new Bytes(ByteUtil.fromString(tag.name)),len,len); } for (Bytes field : currentFieldLengths.keySet()) { if (!lengths.containsKey(field)) { lengths.put(field,new FieldLengthList(field)); } lengths.get(field).add(doc.identifier,currentFieldLengths.get(field)); } }
@Override public TObjectIntHashMap<ItemVO<Integer,Integer>> extractData(ResultSet rs) { TObjectIntHashMap<ItemVO<Integer,Integer>> map = new TObjectIntHashMap<>(); int itemId,itemTypeId,tenantId,cnt = 0; try { while (rs.next()) { itemId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_COLUMN_NAME); itemTypeId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_TYPE_COLUMN_NAME); tenantId = rs.getInt(BaseActionDAO.DEFAULT_TENANT_COLUMN_NAME); cnt = rs.getInt("cnt"); map.put(new ItemVO<>(tenantId,itemId,itemTypeId),cnt); } // optimization: replaces former adjustSupport method minSupp = cnt; } catch (sqlException e) { logger.error("An error occured during ResultSet extraction",e); throw new RuntimeException(e); } return map; }
@Override public ArrayList<TupleVO> getTuples(final int support) throws Exception { final ArrayList<TupleVO> ret = new ArrayList<>(); // Set<ItemVO<Integer,Integer>> mainKeys = map.keySet(); Set<Entry<ItemVO<Integer,Integer>,TObjectIntHashMap<ItemVO<Integer,Integer>>>> entries = map.entrySet(); for (final Entry<ItemVO<Integer,Integer>>> entry : entries) { entry.getValue().forEachEntry(new TObjectIntProcedure<ItemVO<Integer,Integer>>() { public boolean execute(ItemVO<Integer,Integer> a,int b) { if (b >= support) { ret.add(new TupleVO(entry.getKey(),a,b)); } return true; } }); } return ret; }
public TObjectIntHashMap<ItemVO<Integer,Integer>> map = new TObjectIntHashMap<ItemVO<Integer,Integer>>(); int itemId,cnt = 0; try { while (rs.next()) { itemId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_COLUMN_NAME); itemTypeId = rs.getInt(BaseActionDAO.DEFAULT_ITEM_TYPE_COLUMN_NAME); tenantId = rs.getInt(BaseActionDAO.DEFAULT_TENANT_COLUMN_NAME); cnt = rs.getInt("cnt"); map.put(new ItemVO<Integer,Integer>(tenantId,e); throw new RuntimeException(e); } return map; }
public void testTPrimitiveHashMap() { TObjectIntMap<String> map = new TObjectIntHashMap<String>(); // Add 5,remove the first four,repeat String[] to_remove = new String[ 4 ]; int batch_index = 0; for( String s : Constants.STRING_OBJECTS ) { if ( batch_index < 4 ) { to_remove[ batch_index ] = s; } map.put( s,s.length() ); batch_index++; if ( batch_index == 5 ) { for( String s_remove : to_remove ) { map.remove( s_remove ); } batch_index = 0; } } }
public void testTrove2PrimitiveHashMap() { gnu.trove.TObjectIntHashMap<String> map = new gnu.trove.TObjectIntHashMap<String>(); // Add 5,s.length() ); batch_index++; if ( batch_index == 5 ) { for( String s_remove : to_remove ) { map.remove( s_remove ); } batch_index = 0; } } }
public void testGetMap() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; raw_map.put( keys[i],map.getMap() ); }
public void testContainsKey() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> map = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; map.put( keys[i],map.containsKey( new Object() ) ); }
public void testContainsValue() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> map = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; map.put( keys[i],map.containsValue( val ) ); }
public void testPutAllMap() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> control = new TObjectIntHashMap<String>(); for ( int i = 0; i < element_count; i++ ) { keys[i] = Integer.toString( i + 1 ); vals[i] = i + 1; control.put( keys[i],raw_map ); }
public void testClear() { int element_count = 20; String[] keys = new String[element_count]; int[] vals = new int[element_count]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>(); Map<String,map.size() ); assertNull( map.get( keys[5] ) ); }
public void testValues() { int element_count = 20; String[] keys = new String[element_count]; Integer[] vals = new Integer[element_count]; TObjectIntMap<String> raw_map = new TObjectIntHashMap<String>( element_count,values_collection.size() ); List<Integer> values_list = new ArrayList<Integer>( values_collection ); for ( int i = 0; i < element_count; i++ ) { assertTrue( values_list.contains( vals[i] ) ); } }
@SuppressWarnings({"unchecked"}) public void testSerialize() throws Exception { Integer[] vals = {1138,deserialized ); }
private void readobject (ObjectInputStream in) throws IOException,ClassNotFoundException { lock = new reentrantreadwritelock(); lock.writeLock().lock(); try { int version = in.readInt(); int size = in.readInt(); entries = new ArrayList(size); map = new TObjectIntHashMap(size); for (int i = 0; i < size; i++) { Object o = in.readobject(); map.put(o,i); entries.add(o); } growthStopped = in.readBoolean(); entryClass = (Class) in.readobject(); if (version > 0) { // instanced id added in version 1S instanceId = (VMID) in.readobject(); } } finally { lock.writeLock().unlock(); } }
@Test public void testCollectPubDates() throws Exception { final List<scoredDocument> fakeData = mkRankedList( SD("doc0",1.0),SD("doc-missing",0.5),SD("doc1",0.3) ); Assert.assertEquals(3,fakeData.size()); TObjectIntHashMap<String> pubdates = new TObjectIntHashMap<String>(); pubdates.put("doc17",1777); pubdates.put("doc0",1888); pubdates.put("doc1",1999); List<scoredDate> dates = ExtractDates.toDates(ExtractDates.collectPubDates(fakeData,pubdates)); Assert.assertEquals(2,dates.size()); Assert.assertEquals(1.0,dates.get(0).score,0.001); Assert.assertEquals(0.3,dates.get(1).score,0.001); Assert.assertEquals(1888,dates.get(0).year); Assert.assertEquals(1999,dates.get(1).year); }
private void readobject (ObjectInputStream in) throws IOException,ClassNotFoundException { // in.defaultReadobject (); int version = in.readInt (); // version int numVariables = in.readInt (); var2idx = new TObjectIntHashMap (numVariables); for (int vi = 0; vi < numVariables; vi++) { Variable var = (Variable) in.readobject (); var2idx.put (var,vi); } int numRows = in.readInt (); values = new ArrayList (numRows); for (int ri = 0; ri < numRows; ri++) { Object[] row = (Object[]) in.readobject (); values.add (row); } scale = (version >= 2) ? in.readDouble () : 1.0; }
@Test public void testAddRemoveSearchMultiResultMap3() { DigramStringSearchHistogram digramHistogram = new DigramStringSearchHistogram(); String desiredResultId = "result1"; String desiredResultId2 = "result2"; digramHistogram.add("word1","word2",desiredResultId); digramHistogram.add("word1","word3",desiredResultId2); digramHistogram.remove("word1",desiredResultId); TObjectIntHashMap<String> results = digramHistogram.getSearchResults(toSet("word1 word2"),1); assertEquals(0,results.size()); results = digramHistogram.getSearchResults(toSet("word1 word3"),1); assertEquals(1,results.size()); // only 1 result returned assertTrue(results.contains(desiredResultId2)); // desired result key contained assertEquals(1,results.get(desiredResultId2)); // desired result has correct weight }
@Override public void addDocument(Document doc) throws IOException { // add the document lengths.get(document).add(doc.identifier,currentFieldLengths.get(field)); } }
public static void writeData(String file,TObjectIntHashMap<String> data){ BufferedWriter writer; try { writer = new BufferedWriter(new FileWriter(file)); for (String s : data.keySet()) { writer.append(data.get(s) + "\t" + s); writer.newLine(); } writer.flush(); writer.close(); } catch (Exception e){ e.printstacktrace(); } }
public static void write(TObjectIntHashMap<String> uri_id,boolean append,String outFile){ BufferedWriter writer; try { writer = new BufferedWriter(new FileWriter(outFile,append)); for (String s : uri_id.keySet()) { writer.append(uri_id.get(s) + "\t" + s); writer.newLine(); } writer.flush(); writer.close(); } catch (Exception e){ e.printstacktrace(); } }
public static void computeIndex(String file,TObjectIntHashMap<String> value_id,HashSet<String> labels){ if(new File(file).exists()){ try{ BufferedReader br = new BufferedReader(new FileReader(file)); String line = null; int index = 1; while((line=br.readLine()) != null){ String[] vals = line.split("\t"); for(String s : labels){ value_id.put(s + "-" + vals[0],index++); value_id.put(s + "-inv_" + vals[0],index++); } } br.close(); } catch(Exception e){ e.printstacktrace(); } } }
public static void loadInputMetadataID(String Metadata_file_index,String input_uri,TIntIntHashMap input_Metadata_id){ TObjectIntHashMap<String> Metadata_index = new TObjectIntHashMap<String>(); loadindex(Metadata_file_index,Metadata_index); try{ BufferedReader br = new BufferedReader(new FileReader(input_uri)); String line = null; while((line=br.readLine()) != null){ String[] vals = line.split("\t"); if(Metadata_index.containsKey(vals[1])); input_Metadata_id.put(Integer.parseInt(vals[0]),Metadata_index.get(vals[1])); } br.close(); } catch(Exception e){ e.printstacktrace(); } }
/** * Load properties from XML file */ private void loadProps(){ props = new NTree(); props_index = new TObjectIntHashMap<String>(); try { // load properties map from XML file XMLUtils.parseXMLFile(propsFile,props_index,props,inverseProps); logger.debug("Properties tree loading."); // write properties index file TextFileUtils.writeData(propsIndexFile,props_index); } catch (Exception e1) { // Todo Auto-generated catch block e1.printstacktrace(); } }
/** * Constuctor */ public MultiPropQueryExecutor(String uri,int uri_id,NTree props,TObjectIntHashMap<String> props_index,String graphURI,String endpoint,SynchronizedCounter counter,TObjectIntHashMap<String> Metadata_index,TextFileManager textWriter,ItemFileManager fileManager,boolean inverseProps,boolean caching){ this.uri = uri; this.props = props; this.props_index = props_index; this.graphURI = graphURI; this.endpoint = endpoint; this.counter = counter; this.textWriter = textWriter; this.Metadata_index = Metadata_index; this.model = null; this.fileManager = fileManager; this.inverseProps = inverseProps; this.itemTree = new PropertyIndexedItemTree(uri_id); this.caching = caching; }
gnu.trove.map.hash.TObjectLongHashMap的实例源码
@Override public NodeParameters clone() { NodeParameters duplicate = new NodeParameters(); if (keyMapping != null) { duplicate.keyMapping = new HashMap<>(this.keyMapping); } if (boolMap != null) { duplicate.boolMap = new TObjectByteHashMap<>(boolMap); } if (longMap != null) { duplicate.longMap = new TObjectLongHashMap<>(longMap); } if (doubleMap != null) { duplicate.doubleMap = new TObjectDoubleHashMap<>(doubleMap); } if (stringMap != null) { duplicate.stringMap = new HashMap<>(this.stringMap); } return duplicate; }
@Override public NodeParameters clone() { NodeParameters duplicate = new NodeParameters(); if (keyMapping != null) { duplicate.keyMapping = new HashMap<>(this.keyMapping); } if (boolMap != null) { duplicate.boolMap = new TObjectByteHashMap<>(boolMap); } if (longMap != null) { duplicate.longMap = new TObjectLongHashMap<>(longMap); } if (doubleMap != null) { duplicate.doubleMap = new TObjectDoubleHashMap<>(doubleMap); } if (stringMap != null) { duplicate.stringMap = new HashMap<>(this.stringMap); } return duplicate; }
public static TObjectLongHashMap loadTXT2LongGZMap(String mapFile,boolean reverse) throws IOException { long time = System.currentTimeMillis(); TObjectLongHashMap idMap = new TObjectLongHashMap(); BufferedReader br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(mapFile)))); String line; String[] parts; while ((line = br.readLine()) != null) { parts = line.split(SEP); try { if (!reverse) { idMap.put(parts[1],Long.parseLong(parts[0])); } else { idMap.put(parts[0],Long.parseLong(parts[1])); } } catch (java.lang.Arrayindexoutofboundsexception ex) { logger.info(line); System.exit(-1); } } logger.info(((System.currentTimeMillis() - time) / 1000d) + "s"); return idMap; }
public TObjectLongMap<Rule<T>> getUsedRules() { TObjectLongMap<Rule<T>> rules = new TObjectLongHashMap<Rule<T>>(Constants.DEFAULT_CAPACITY,Constants.DEFAULT_LOAD_FACTOR,-1); List<Rule<T>> iteratedList = new ArrayList<Rule<T>>(32); List<Rule<T>> newList = new ArrayList<Rule<T>>(32); iteratedList.add(this); do { for (Rule<T> rule : iteratedList) { for (Symbol<T> sym: rule.symbols) { if (sym instanceof NonTerminal<?>) { Rule<T> newRule = ((NonTerminal<T>)sym).getRule(); if (rules.adjustOrPutValue(newRule,1,1) == 1) // increase counter. new rule? newList.add(newRule); } } } List<Rule<T>> nextNewList = iteratedList; iteratedList = newList; newList = nextNewList; newList.clear(); } while (!iteratedList.isEmpty()); return rules; }
/** * {@inheritDoc} * @see com.heliosapm.shorthand.datamapper.IDataMapper#put(long,gnu.trove.map.hash.TObjectLongHashMap,long[]) */ @Override public void put(final long address,final long[] data) { HeaderOffset.Touch.set(address,1); int enumIndex = (int)HeaderOffset.EnumIndex.get(address); int bitMask = (int)HeaderOffset.BitMask.get(address); TObjectLongHashMap<T> offsets = (TObjectLongHashMap<T>) EnumCollectors.getInstance().offsets(enumIndex,bitMask); if(offsets.isEmpty()) return; offsets.forEachEntry(new TObjectLongProcedure<ICollector<?>>() { @Override public boolean execute(ICollector<?> collector,long offset) { if(!collector.isPreApply()) { collector.apply(address+offset,data); } return true; } }); }
public PlayTimeManager() { this.totalPlaytimeMap = new TObjectLongHashMap<>(); this.sessionTimestamps = new TObjectLongHashMap<>(); this.config = new FileConfig("play-times.yml"); this.reloadplaytimeData(); Bukkit.getPluginManager().registerEvents(this,PracticePlugin.getInstance()); }
public static void testBug3067307() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
public static void testBug3067307_noAutoCompact() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); testHash.setAutoCompactionFactor( 0 ); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
/** * Creates a new DeltaManager */ private DeltaManager() { final int initialDeltaCapacity = ConfigurationHelper.getIntSystemThenEnvProperty(DELTA_CAPACITY,DELTA_CAPACITY_DEFAULT); final float initialDeltaLoadFactor = ConfigurationHelper.getFloatSystemThenEnvProperty(DELTA_LOAD_FACTOR,DELTA_LOAD_FACTOR_DEFAULT); longDeltas = new TObjectLongHashMap<java.lang.String>(initialDeltaCapacity,initialDeltaLoadFactor,Long.MIN_VALUE); doubleDeltas = new TObjectDoubleHashMap<java.lang.String>(initialDeltaCapacity,Double.MIN_norMAL); intDeltas = new TObjectIntHashMap<java.lang.String>(initialDeltaCapacity,Integer.MIN_VALUE); longVDeltas = new TObjectLongHashMap<java.lang.String>(initialDeltaCapacity,Long.MIN_VALUE); doubleVDeltas = new TObjectDoubleHashMap<java.lang.String>(initialDeltaCapacity,Double.MIN_norMAL); intVDeltas = new TObjectIntHashMap<java.lang.String>(initialDeltaCapacity,Integer.MIN_VALUE); JMXHelper.registerMBean(OBJECT_NAME,this); }
public NodeParameters set(String key,long value) { ensureKeyType(key,Type.LONG); if (longMap == null) { longMap = new TObjectLongHashMap<>(); } longMap.put(key,value); return this; }
public static void testBug3067307() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
public static void testBug3067307_noAutoCompact() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); testHash.setAutoCompactionFactor( 0 ); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
@Override @SuppressWarnings("null") public @NonNull TObjectLongHashMap<Duplex> getIssues() { if (issues == null) { issues = new TObjectLongHashMap<>(); } return issues; }
public NodeParameters set(String key,value); return this; }
public static void testBug3067307() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
public static void testBug3067307_noAutoCompact() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); testHash.setAutoCompactionFactor( 0 ); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
public StatsWordmatch() { this.available = new HashMap<String,Pattern>(); addAvail(new EmoticonPatternProvider()); addAvail(new URLPatternProvider()); addAvail(new TimePatternProvider()); addAvail(new PunctuationPatternProvider()); TwitterStuffPatternProvider tpp = new TwitterStuffPatternProvider(); addAvail("TwitterStuff.hashtags",tpp.hashtagPatternString()); addAvail("TwitterStuff.retweets",tpp.retweetPatternString()); addAvail("TwitterStuff.username",tpp.usernamePatternString()); addAvail("EdgePunctuation",EdgePunctuationPatternProvider.edgePuncPattern()); this.counts = new TObjectLongHashMap<String>(); }
public static void convertTextGraphWithLongMapGZ(String inputGraph,String outputGraph,String mapFile) throws IOException { TObjectLongHashMap map = loadTXT2LongGZMap(mapFile,false); long time = System.currentTimeMillis(); BufferedReader br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(inputGraph)))); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(outputGraph)))); String line,newLine; long id1,id2; String[] parts; while ((line = br.readLine()) != null) { parts = line.split(SEP); id1 = map.get(parts[0]); id2 = map.get(parts[1]); if (id1 != 0 && id2 != 0) { newLine = "" + id1 + SEP + id2 + (parts.length > 2 ? (SEP + parts[2]) : ""); bw.write(newLine); bw.newLine(); } } bw.flush(); bw.close(); br.close(); logger.info(((System.currentTimeMillis() - time) / 1000d) + "s"); }
public PerformanceMonitorImpl() { _activityStack = new Stack<Activity>(); _metricData = new LinkedList<TObjectLongMap<String>>(); _runningTotals = new TObjectLongHashMap<String>(); _timerTicksPerSecond = Sys.getTimerResolution(); _currentData = new TObjectLongHashMap<String>(); _spikeData = new TObjectDoubleHashMap<String>(); _runningThreads = TCollections.synchronizedMap(new TObjectIntHashMap<String>()); _stoppedThreads = TCollections.synchronizedMap(new TObjectIntHashMap<String>()); _lastRunningThreads = new TObjectIntHashMap<String>(); _timeFactor = 1000.0 / _timerTicksPerSecond; _mainThread = Thread.currentThread(); }
public static void testBug3067307() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
public static void testBug3067307_noAutoCompact() { TObjectLongHashMap<String> testHash = new TObjectLongHashMap<String>(); testHash.setAutoCompactionFactor( 0 ); final int c = 1000; for ( long i = 1; i < c; i++ ) { final String data = "test-" + i; testHash.put( data,i ); testHash.remove( data ); } }
/** * {@inheritDoc} * @see com.heliosapm.shorthand.datamapper.IDataMapper#prePut(long,long[]) */ @Override public void prePut(long address,long[] data) { int enumIndex = (int)HeaderOffset.EnumIndex.get(address); int bitMask = (int)HeaderOffset.BitMask.get(address); TObjectLongHashMap<T> offsets = (TObjectLongHashMap<T>) EnumCollectors.getInstance().offsets(enumIndex,bitMask); if(offsets.isEmpty()) return; ICollector<?>[] preApplies = (ICollector<?>[]) offsets.iterator().key().getPreApplies(bitMask); if(preApplies.length==0) return; for(ICollector<?> collector: preApplies) { collector.apply(address+offsets.get(collector),data); } }
public ChronicleStore() throws IOException { file = FileUtils.createTempFile(); LOGGER.info("Using " + file.getAbsolutePath()); chronicle = new IndexedChronicle(file.getAbsolutePath()); posMap = new TObjectLongHashMap<Serializable>(Constants.DEFAULT_CAPACITY,NO_ENTRY); posSizeMap = new TLongIntHashMap(Constants.DEFAULT_CAPACITY,NO_ENTRY,NO_ENTRY); freePosSizeMap = new TIntObjectHashMap<TLongList>(Constants.DEFAULT_CAPACITY,NO_ENTRY); freePosMaxSize = 0; appender = chronicle.createAppender(); randomAccessor = chronicle.createExcerpt(); }
public TscStreamReductor() { this(new TLongHashSet(),new TObjectLongHashMap<>()); }
public AutoDeltaStringLongMap() { this.changes = new ArrayList<>(5); this.container = new TObjectLongHashMap<>(); this.baselineCommandCount = 0; }
public AutoDeltaObjectLongMap(Function<ByteBuffer,K> keyCreator) { this.changes = new ArrayList<>(5); this.container = new TObjectLongHashMap<>(); this.baselineCommandCount = 0; this.keyCreator = keyCreator; }
@Override protected void setup(Context context) throws IOException,InterruptedException { counter = new TObjectLongHashMap<String>(); }
@NonNull TObjectLongHashMap<Duplex> getIssues();
今天关于放入HashMap 在jsonobject中和hashmap存入元素的方法的分享就到这里,希望大家有所收获,若想了解更多关于gnu.trove.map.hash.TIntObjectHashMap的实例源码、gnu.trove.map.hash.TLongObjectHashMap的实例源码、gnu.trove.map.hash.TObjectIntHashMap的实例源码、gnu.trove.map.hash.TObjectLongHashMap的实例源码等相关知识,可以在本站进行查询。
本文标签: