当前位置: 首页>>代码示例>>C#>>正文


C# HashMap.put方法代码示例

本文整理汇总了C#中HashMap.put方法的典型用法代码示例。如果您正苦于以下问题:C# HashMap.put方法的具体用法?C# HashMap.put怎么用?C# HashMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HashMap的用法示例。


在下文中一共展示了HashMap.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: test

	public static int test() {
		var map = new HashMap<string, Object>();
		map.put("str1", new Object());
		map.put("str2", new Object());
			
		var map2 = new HashMap<string, Object>();
		foreach (var e in map.entrySet()) {
			map2.put(e.getKey(), e.getValue());
		}
		return map2.size();
	}
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:11,代码来源:GenericNestedInterface.stab.cs

示例2: getUmbrellaWorld_Xt_to_Xtm1_Map

        public static Map<RandomVariable, RandomVariable> getUmbrellaWorld_Xt_to_Xtm1_Map()
        {
            Map<RandomVariable, RandomVariable> tToTm1StateVarMap = new HashMap<RandomVariable, RandomVariable>();
            tToTm1StateVarMap.put(ExampleRV.RAIN_t_RV, ExampleRV.RAIN_tm1_RV);

            return tToTm1StateVarMap;
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:7,代码来源:GenericTemporalModelFactory.cs

示例3: TestCache

 public void TestCache() {
    WeakCache cache = new WeakCache();
    Dictionary map = new HashMap();
    for(int i = 0; i < LOAD_COUNT; i++) {
       String key = String.valueOf(i);
       cache.cache(key, key);
       map.put(key, key);
    }
    for(int i = 0; i < LOAD_COUNT; i++) {
       String key = String.valueOf(i);
       AssertEquals(cache.fetch(key), key);
       AssertEquals(map.get(key), cache.fetch(key));
    }
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:14,代码来源:WeakCacheTest.cs

示例4: getUmbrellaWorldNetwork

        /**
         * Return a Dynamic Bayesian Network of the Umbrella World Network.
         * 
         * @return a Dynamic Bayesian Network of the Umbrella World Network.
         */

        public static DynamicBayesianNetwork getUmbrellaWorldNetwork()
        {
            FiniteNode prior_rain_tm1 = new FullCPTNode(ExampleRV.RAIN_tm1_RV,
                                                        new double[] {0.5, 0.5});

            BayesNet priorNetwork = new BayesNet(prior_rain_tm1);

            // Prior belief state
            FiniteNode rain_tm1 = new FullCPTNode(ExampleRV.RAIN_tm1_RV,
                                                  new double[] {0.5, 0.5});
            // Transition Model
            FiniteNode rain_t = new FullCPTNode(ExampleRV.RAIN_t_RV, new double[]
                                                                         {
                                                                             // R_t-1 = true, R_t = true
                                                                             0.7,
                                                                             // R_t-1 = true, R_t = false
                                                                             0.3,
                                                                             // R_t-1 = false, R_t = true
                                                                             0.3,
                                                                             // R_t-1 = false, R_t = false
                                                                             0.7
                                                                         }, rain_tm1);
            // Sensor Model
            FiniteNode umbrealla_t = new FullCPTNode(ExampleRV.UMBREALLA_t_RV,
                                                     new double[]
                                                         {
                                                             // R_t = true, U_t = true
                                                             0.9,
                                                             // R_t = true, U_t = false
                                                             0.1,
                                                             // R_t = false, U_t = true
                                                             0.2,
                                                             // R_t = false, U_t = false
                                                             0.8
                                                         }, rain_t);

            Map<RandomVariable, RandomVariable> X_0_to_X_1 = new HashMap<RandomVariable, RandomVariable>();
            X_0_to_X_1.put(ExampleRV.RAIN_tm1_RV, ExampleRV.RAIN_t_RV);
            Set<RandomVariable> E_1 = new HashSet<RandomVariable>();
            E_1.add(ExampleRV.UMBREALLA_t_RV);

            return new DynamicBayesNet(priorNetwork, X_0_to_X_1, E_1, rain_tm1);
        }
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:49,代码来源:DynamicBayesNetExampleFactory.cs

示例5: getPerceptSequenceActions

	//
	// PRIVATE METHODS
	//
	private static Map<List<Percept>, Action> getPerceptSequenceActions() {
		Map<List<Percept>, Action> perceptSequenceActions = new HashMap<List<Percept>, Action>();

		// NOTE: While this particular table could be setup simply
		// using a few loops, the intent is to show how quickly a table
		// based approach grows and becomes unusable.
		List<Percept> ps;
		//
		// Level 1: 4 states
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_RIGHT);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_SUCK);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_LEFT);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Dirty));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_SUCK);

		//
		// Level 2: 4x4 states
		// 1
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_RIGHT);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_SUCK);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_LEFT);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Dirty));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_SUCK);
		// 2
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_RIGHT);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_SUCK);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_LEFT);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Dirty));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_SUCK);
		// 3
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Clean), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_RIGHT);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Clean), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_A,
				VacuumEnvironment.LocationState.Dirty));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_SUCK);
		ps = createPerceptSequence(new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Clean), new VacuumEnvPercept(
				VacuumEnvironment.LOCATION_B,
				VacuumEnvironment.LocationState.Clean));
		perceptSequenceActions.put(ps, VacuumEnvironment.ACTION_MOVE_LEFT);
//.........这里部分代码省略.........
开发者ID:PaulMineau,项目名称:AIMA.Net,代码行数:101,代码来源:TableDrivenVacuumAgent.cs

示例6: TestSuperType

 public void TestSuperType() {
    Map<String, String> clazMap = new HashMap<String, String> ();
    clazMap.put("subtype1", SubType1.class.getName());
开发者ID:ngallagher,项目名称:simplexml,代码行数:3,代码来源:SuperTypeTest.cs

示例7: getExtensionsForFragment

        public HashMap<StyleExtensionMapEntry> getExtensionsForFragment(HtmlElement element)
        {
            var hashmap = new HashMap<StyleExtensionMapEntry>();
            //We need to loop over all of the relevant entries in the map that define some behavior
            var allEntries = map.getAllRandoriSelectorEntries();

            for ( var i=0; i<allEntries.length; i++) {
                JsArray<HtmlElement> implementingNodes = findChildNodesForCompoundSelector(element, allEntries[i]);

                //For each of those entries, we need to see if we have any elements in this DOM fragment that implement any of those classes
                for ( var j=0; j<implementingNodes.length; j++) {

                    var implementingElement = implementingNodes[ j ];
                    var value = hashmap.get( implementingElement );

                    if ( value == null ) {
                        //Get the needed entry
                        var extensionEntry = map.getExtensionEntry(allEntries[i]);

                        //give us a copy so we can screw with it at will
                        hashmap.put(implementingElement, extensionEntry.clone());
                    } else {
                        //We already have data for this node, so we need to merge the new data into the existing one
                        var extensionEntry = map.getExtensionEntry(allEntries[i]);

                        extensionEntry.mergeTo( (StyleExtensionMapEntry)value );
                    }
                }
            }

            //return the hashmap which can be queried and applied to the Dom
            return hashmap;
        }
开发者ID:griffith-computing,项目名称:Randori,代码行数:33,代码来源:StyleExtensionManager.cs

示例8: initializeAvailable

 private static void initializeAvailable()
 {
     TimeZone[] zones = TimeZones.getTimeZones();
     AvailableZones = new HashMap<String, TimeZone>(
             (zones.Length + 1) * 4 / 3);
     AvailableZones.put(GMT.getID(), GMT);
     for (int i = 0; i < zones.Length; i++)
     {
         AvailableZones.put(zones[i].getID(), zones[i]);
     }
 }
开发者ID:sailesh341,项目名称:JavApi,代码行数:11,代码来源:TimeZone.cs

示例9: Main

        static void Main(string[] args)
        {
            HashMap hm = new HashMap();
            hm.put(3, 3);
            hm.put(103, 4);
            hm.put(203, 5);
            hm.put(4, 44);

            int k = hm.get(4);
            int k1 = hm.get(203);
            hm.delete(203);
            int k2 = hm.get(203);
            int k3 = hm.get(4);
            int k4 = 10;
        }
开发者ID:kerydan,项目名称:CrackingTheCodingInterview,代码行数:15,代码来源:Hash.cs

示例10: Main

    /**
     * ExampleF53
     *
     * This example demonstrates registration and dispense of the Fujitsu F53
     * using the Envoy API.
     *
     * NOTE: A running Envoy service is necessary to run this example.
     *
     * TO COMPILE AND RUN IN WINDOWS CONSOLE
     * -------------------------------------
     * C:\test> csc /r:LibEnvoyAPI.dll,IKVM.OpenJDK.Core.dll,IKVM.OpenJDK.Util.dll,IKVM.OpenJDK.Naming.dll,IKVM.OpenJDK.Remoting.dll,IKVM.Runtime.dll /lib:[path_to_IKVM]\bin ExampleF53.cs
     * C:\test> ExampleF53.exe
     *
     *
     * TO COMPILE AND RUN IN LINUX TERMINAL
     * ------------------------------------
     * ~/test$ dmcs -r:LibEnvoyAPI.dll,/usr/lib/ikvm/IKVM.OpenJDK.Core.dll,/usr/lib/ikvm/IKVM.OpenJDK.Util.dll,/usr/lib/ikvm/IKVM.OpenJDK.Remoting.dll,/usr/lib/ikvm/IKVM.Runtime.dll ExampleF53.cs
     * ~/test$ ExampleF53.exe
     *
     * The program first obtains the Envoy system object and then registers
     * the device if not already registered. It obtains the device object
     * via the logical device name (LDN). Then, denominations are mapped to the
     * logical device. This enables Envoy to keep track of which denominations
     * are in each cassette and is dependent on a specific magnet setting.
     *
     * After that, bill parameters are set. In this step a minimum and maximum
     * bill length is written to F53 memory, along with bill thickness. This allows
     * the F53 to throw errors if it encounters a misfeed, or an irregular or damaged
     * bill.
     *
     * Finally, the F53 is made to dispense one bill each from the cassettes in
     * position 1 and position 2.
     *
     * @param args - Command line arguments, not used.
     */
    public static void Main(String[] args)
    {
        try
        {
            // Get the Envoy System Object.
            Console.WriteLine("Getting the Envoy System object.");
            IEnvoySystem envoySystem = (IEnvoySystem)Naming.lookup("//localhost/envoy/system");

            // Track the expected device path for the F53.
            String devicePath = null;

            // Try to find a registered F53 device first.
            Console.WriteLine("Attempting to find a registered F53.");
            foreach (String deviceName in envoySystem.getRegisteredDeviceNames())
            {
                DeviceInformation deviceInformation = envoySystem.getRegisteredDeviceInformation(deviceName);

                if (deviceInformation.getDeviceType() == DeviceType.FUJITSU_F53)
                {
                    devicePath = envoySystem.getDevicePath(deviceName);
                    break;
                }
            }

            // If no registered F53 devices were found, regster an unregistered one.
            if (devicePath == null)
            {
                Console.WriteLine("Attempting to register an attached F53.");
                foreach (DeviceInformation deviceInformation in envoySystem.getAllKnownDeviceInformation())
                {
                    if (deviceInformation.getDeviceType() == DeviceType.FUJITSU_F53)
                    {
                        if (envoySystem.register(F53_DEVICE_NAME, deviceInformation))
                        {
                            devicePath = envoySystem.getDevicePath(F53_DEVICE_NAME);
                            break;
                        }
                    }
                }
            }

            // Look up the device over RMI.  Success is if the device is not
            // null.
            if (devicePath != null)
            {
                Console.WriteLine("Looking up F53 device.");
                IF53Device device = (IF53Device) Naming.lookup(devicePath);

                if (device != null)
                {
                    Console.WriteLine("Setting Denomination Mappings to USD.");
                    device.setMediaMappings(FujitsuDefaultMediaMappings.getMapping(DeviceType.FUJITSU_F53, CurCodeEnum.USD));

                    // Configure the F53 for USD Bill Parameters & no polymer support.
                    Console.WriteLine("Performing Mechanical Reset.");
                    bool bPolymer = false;
                    byte[] bBillLengths = { (byte)0x9A, (byte)0x9A };
                    byte[] bBillThicks = { (byte)0x0D, (byte)0x0D };
                    FujitsuBillParams f53params = new FujitsuBillParams(bBillLengths, bBillThicks, bPolymer);
                    FujitsuMechanicalResetRsp response = device.mechanicalReset(f53params);

                    // Perform a Dispense By Position on the F53.
                    Map posToCount = new HashMap();
                    posToCount.put(java.lang.Integer.valueOf(1), java.lang.Integer.valueOf(1)); // Dispense 1 Note(s) from Position #1.
                    posToCount.put(java.lang.Integer.valueOf(2), java.lang.Integer.valueOf(1)); // Dispense 1 Note(s) from Position #2
//.........这里部分代码省略.........
开发者ID:coinme,项目名称:envoy,代码行数:101,代码来源:ExampleF53.cs

示例11: compileCore


//.........这里部分代码省略.........
					Environment.trace(this, "error (" + error.Line + ", " + error.Column + ") " + error.Filename + ": " + error.Message);
				}

				if (!hasErrors) {
					var dependencyInfo = new DependencyInfo();
					results.DependencyInfo = dependencyInfo;
					var allTypes = new HashSet<String>();
	
					// Copy informations from unbuilt files
					if (parameters.DependencyInfo != null) {
						var unbuiltFiles = allFiles.getAllProjectRelativeNames();
						unbuiltFiles = unbuiltFiles.except(filesToCompile.select(p => allFiles.getProjectRelativeName(p)));
						unbuiltFiles = unbuiltFiles.except(deletedFiles);
						foreach (var file in unbuiltFiles) {
							foreach (var type in parameters.DependencyInfo.getFileContents(file)) {
								allTypes.add(type);
								dependencyInfo.addFileToTypeRelation(file, type);
								foreach (var refType in parameters.DependencyInfo.getReferencedTypes(type)) {
									dependencyInfo.addTypeToTypeRelation(type, refType);
								}
							}
						}
					}
					
					// Collect the types and update the dependencies.
					var typeMembers = new HashMap<IFile, Iterable<TypeMemberNode>>();
					foreach (var file in filesToCompile) {
						var fileName = allFiles.getProjectRelativeName(file);
						var compilationUnit = compilationUnits[fileName];
						if (compilationUnit == null) {
							continue;
						}
						var members = SyntaxTreeHelper.getTypeMembers(compilationUnit);
						typeMembers.put(file, members);
						foreach (var member in members) {
							var typeName = member.getUserData(typeof(TypeInfo)).FullName;
							dependencyInfo.addFileToTypeRelation(fileName, typeName);
							allTypes.add(typeName);
						}
					}

					if (parameters.DependencyInfo != null) {
						// Copy the types ignored by this compilation
						var missingTypes = new HashSet<TypeInfo>();
						foreach (var t in allTypes.where(p => p.indexOf('$') == -1 && !typeSystem.typeExists(p))) {
							if (hasErrors = !parameters.DependencyInfo.getReferencedTypes(t).all(p => allTypes.contains(p))) {
								Environment.trace(this, "Incremental build failed: a type was deleted");
								break;
							}
							missingTypes.add(parameters.TypeSystem.getType(t));
						}
						if (!hasErrors) {
							JvmTypeSystemHelper.cloneTypes(missingTypes, typeSystem);
						}
					}
					
					if (!hasErrors) {
						// Compute the dependencies in the compiled files
						foreach (var member in filesToCompile.select(p => typeMembers[p]).where(p => p != null).selectMany(p => p)) {
							foreach (var t in SyntaxTreeHelper.getTypeMemberDependencies(member)
									.intersect(allTypes.select(p => JvmTypeSystemHelper.getType(typeSystem, p)))) {
								dependencyInfo.addTypeToTypeRelation(member.getUserData(typeof(TypeInfo)).FullName, t.FullName);
							}
						}
	
						results.TypeSystem = typeSystem;
开发者ID:nagyistoce,项目名称:cnatural-language,代码行数:67,代码来源:SourceCompiler.stab.cs

示例12: Main

        static void Main(string[] args)
        {
            RezeptModel rezeptBasiskuchen = new RezeptModel();
            rezeptBasiskuchen.SetName("Basiskuchen");
            rezeptBasiskuchen.SetZutatMehl(500);
            rezeptBasiskuchen.SetZutatZucker(100);
            rezeptBasiskuchen.SetZutatButter(100);
            rezeptBasiskuchen.SetZutatEier(4);

            RezeptModel rezeptZweiterkuchen = new RezeptModel();
            rezeptZweiterkuchen.SetName("Zweiter Kuchen");
            rezeptZweiterkuchen.SetZutatMehl(520);
            rezeptZweiterkuchen.SetZutatZucker(120);
            rezeptZweiterkuchen.SetZutatButter(120);
            rezeptZweiterkuchen.SetZutatEier(4);

            RezeptModel rezeptDritterkuchen = new RezeptModel();
            rezeptDritterkuchen.SetName("Dritter Kuchen");
            rezeptDritterkuchen.SetZutatMehl(250);
            rezeptDritterkuchen.SetZutatZucker(55);
            rezeptDritterkuchen.SetZutatButter(90);
            rezeptDritterkuchen.SetZutatEier(2);

            RezeptModel rezeptVierterkuchen = new RezeptModel();
            rezeptVierterkuchen.SetName("Vierter Kuchen");
            rezeptVierterkuchen.SetZutatMehl(400);
            rezeptVierterkuchen.SetZutatZucker(120);
            rezeptVierterkuchen.SetZutatButter(130);
            rezeptVierterkuchen.SetZutatEier(3);

            RezeptModel vorhandeneZutaten = new RezeptModel();
            vorhandeneZutaten.SetZutatMehl(400);
            vorhandeneZutaten.SetZutatZucker(120);
            vorhandeneZutaten.SetZutatButter(1130);
            vorhandeneZutaten.SetZutatEier(3);

            VergleichRezept(vorhandeneZutaten, rezeptBasiskuchen);
            VergleichRezept(vorhandeneZutaten, rezeptZweiterkuchen);
            VergleichRezept(vorhandeneZutaten, rezeptDritterkuchen);
            VergleichRezept(vorhandeneZutaten, rezeptVierterkuchen);

            // Create a HashMap with three key/value pairs.
            HashMap hm = new HashMap();
            hm.put("One", "1");
            hm.put("Two", "2a");
            hm.put("Two", "2b");
            hm.put("Three", "3");

            // Iterate over the HashMap to see what we just put in.
            Set set = hm.entrySet();
            Iterator setIter = set.iterator();
            while (setIter.hasNext())
            {
                System.out.println(setIter.next());
            }

            Console.ReadKey();
        }
开发者ID:Chrysophyceae,项目名称:RecipeFinder,代码行数:58,代码来源:ProgramRezeptFindenHashMap.cs


注:本文中的HashMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。