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


C# HashMap.Put方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            var listOfIntegers = new LinkedList<int> {0, 1, 2, 3, 4, 5, 6, 7};
            listOfIntegers.Remove(2);

            foreach (var entry in listOfIntegers)
            {
                Console.WriteLine(entry);
            }

            var hashMap = new HashMap<String, Int32>();
            hashMap.Put("mike", 4);
            hashMap.Put("chris", 7);

            Console.WriteLine("KEY: 'mike'\t VALUE:{0}", hashMap.GetValue("mike"));

            foreach (var keyValuePair in hashMap)
            {
                Console.WriteLine(keyValuePair);
            }

            var tree = new Tree<int> {4, 6, 9, 2};

            foreach (var value in tree)
            {
                Console.Write("{0}\t", value);
            }

            Console.Read();
        }
开发者ID:mmscibor,项目名称:Data-Structures,代码行数:30,代码来源:Program.cs

示例2: Parse

        public static Map<string, string> Parse(string[] args)
        {
            string[] arr = new string[args.Length];
            args.CopyTo(arr, 0);
            args = arr;

            Map<string, string> options = new HashMap<string, string>();

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i][0] == '-' || args[i][0] == '/') //This start with - or /
                {
                    args[i] = args[i].Substring(1);
                    if (i + 1 >= args.Length || args[i + 1][0] == '-' || args[i + 1][0] == '/') //Next start with - (or last arg)
                    {
                        options.Put(args[i], "null");
                    }
                    else
                    {
                        options.Put(args[i], args[i + 1]);
                        i++;
                    }
                }
            }

            return options;
        }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:27,代码来源:ArgParser.cs

示例3: getChartExamples

        private HashMap getChartExamples()
        {
            HashMap examples = new HashMap();

            ArrayList examplesSet = new ArrayList();

            examplesSet.Add(new ListViewGettingStartedFragment());

            examples.Put("Binding", examplesSet);

            examplesSet = new ArrayList();

            examplesSet.Add(new ListViewReorderFragment());
            examplesSet.Add(new ListViewSwipeToExecuteFragment());
            examplesSet.Add(new ListViewSwipeToRefreshFragment());
            examplesSet.Add(new ListViewItemAnimationFragment());
            examplesSet.Add(new ListViewManualLoadOnDemandFragment());
            examplesSet.Add(new ListViewDataAutomaticLoadOnDemandFragment());
            examplesSet.Add(new ListViewDataOperationsFragment());
            examplesSet.Add(new ListViewLayoutsFragment());

            examples.Put("Features", examplesSet);

            return examples;
        }
开发者ID:camlt,项目名称:Android-samples,代码行数:25,代码来源:ListViewExamples.cs

示例4: addItem

 private void addItem(IList<IMap<String, Object>> data, String title, Intent intent)
 {
    HashMap<String, Object> temp = new HashMap<String, Object>();
    temp.Put(TITLE_KEY, title);
    temp.Put(INTENT_KEY, intent);
    data.Add(temp);
 }
开发者ID:MahendrenGanesan,项目名称:samples,代码行数:7,代码来源:PlusSampleActivity.cs

示例5: getListViewExamples

        private HashMap getListViewExamples()
        {
            HashMap examples = new HashMap();

            ArrayList examplesSet = new ArrayList();

            examplesSet.Add(new ListViewGettingStartedFragment());
            examplesSet.Add(new ListViewLayoutsFragment());
            examplesSet.Add(new ListViewDeckOfCardsFragment());
            examplesSet.Add(new ListViewSlideFragment());
            examplesSet.Add(new ListViewWrapFragment());
            examplesSet.Add(new ListViewItemAnimationFragment());
            examplesSet.Add(new ListViewDataOperationsFragment());

            examples.Put("Features", examplesSet);

            examplesSet = new ArrayList();

            examplesSet.Add(new ListViewReorderFragment());
            examplesSet.Add(new ListViewSwipeToExecuteFragment());
            examplesSet.Add(new ListViewSwipeToRefreshFragment());
            examplesSet.Add(new ListViewManualLoadOnDemandFragment());
            examplesSet.Add(new ListViewSelectionFragment());
            examplesSet.Add(new ListViewDataAutomaticLoadOnDemandFragment());
            examplesSet.Add (new ListViewStickyHeadersFragment ());

            examples.Put("Behaviors", examplesSet);

            return examples;
        }
开发者ID:rafasame,项目名称:Android-samples,代码行数:30,代码来源:ListViewExamples.cs

示例6: getChartExamples

        private HashMap getChartExamples()
        {
            HashMap chartExamples = new HashMap();

            ArrayList result = new ArrayList();

            result.Add(new AreaSeriesFragment());
            result.Add(new LineSeriesFragment());
            result.Add(new CandleStickSeriesFragment());
            result.Add(new DoughnutSeriesFragment());
            result.Add(new HorizontalBarSeriesFragment());
            result.Add(new IndicatorSeriesFragment());
            result.Add(new OhlcSeriesFragment());
            result.Add(new PieSeriesFragment());
            result.Add(new ScatterBubbleSeriesFragment());
            result.Add(new ScatterPointSeriesFragment());
            result.Add(new SplineAreaSeriesFragment());
            result.Add(new SplineSeriesFragment());
            result.Add(new StackAreaSeriesFragment());
            result.Add(new StackBarSeriesFragment());
            result.Add(new StackBarSeriesFragment());
            result.Add(new StackSplineAreaSeriesFragment());
            result.Add(new VerticalBarSeriesFragment());

            chartExamples.Put("Series", result);

            result = new ArrayList();

            result.Add(new ChartLegendFragment());
            result.Add(new GridFeatureFragment());
            result.Add(new PalettesFragment());

            chartExamples.Put("Features", result);

            result = new ArrayList();

            result.Add(new PanAndZoomFragment());
            result.Add(new SelectionBehaviorFragment());
            result.Add(new TooltipBehaviorFragment());
            result.Add(new TrackballBehaviorFragment());

            chartExamples.Put("Behaviors", result);

            result = new ArrayList();

            result.Add(new DateTimeContinuousAxisFragment());
            result.Add(new MultipleAxesFragment());

            chartExamples.Put("Axes", result);

            result = new ArrayList();

            result.Add(new GridLineAnnotationFragment());
            result.Add(new PlotBandAnnotationFragment());

            chartExamples.Put("Annotations", result);

            return chartExamples;
        }
开发者ID:camlt,项目名称:Android-samples,代码行数:59,代码来源:ChartExamples.cs

示例7: QuizListenerService

		public QuizListenerService ()
		{
			var temp = new HashMap (4);
			temp.Put (0, Resource.Drawable.ic_choice_a);
			temp.Put (1, Resource.Drawable.ic_choice_b);
			temp.Put (2, Resource.Drawable.ic_choice_c);
			temp.Put (3, Resource.Drawable.ic_choice_d);
			question_num_to_drawable_id = temp;
		}
开发者ID:supersume,项目名称:monodroid-samples,代码行数:9,代码来源:QuizListenerService.cs

示例8: MomentUtil

      static MomentUtil()
      {
         MOMENT_TYPES = new HashMap<String, String>(9);
         MOMENT_TYPES.Put("AddActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/thing");
         MOMENT_TYPES.Put("BuyActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/a-book");
         MOMENT_TYPES.Put("CheckInActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/place");
         MOMENT_TYPES.Put("CommentActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/blog-entry");
         MOMENT_TYPES.Put("CreateActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/photo");
         MOMENT_TYPES.Put("ListenActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/song");
         MOMENT_TYPES.Put("ReserveActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/restaurant");
         MOMENT_TYPES.Put("ReviewActivity",
                 "https://developers.google.com/+/plugins/snippet/examples/widget");

         MOMENT_LIST = new ArrayList<String>(MomentUtil.MOMENT_TYPES.KeySet());
         Collections.Sort(MOMENT_LIST);

         VISIBLE_ACTIVITIES = MOMENT_TYPES.KeySet().ToArray(new String[0]);
         int count = VISIBLE_ACTIVITIES.Length;
         for (int i = 0; i < count; i++)
         {
            VISIBLE_ACTIVITIES[i] = "http://schemas.google.com/" + VISIBLE_ACTIVITIES[i];
         }
      }
开发者ID:MahendrenGanesan,项目名称:samples,代码行数:30,代码来源:MomentUtil.cs

示例9: GenerateIndexDocuments

 private IDictionary<string, Document> GenerateIndexDocuments(int ndocs)
 {
     IDictionary<string, Document> docs = new HashMap<string, Document>();
     for (int i = 0; i < ndocs; i++)
     {
         Field field = new TextField(FIELD_NAME, "field_" + i, Field.Store.YES);
         Field payload = new StoredField(PAYLOAD_FIELD_NAME, new BytesRef("payload_" + i));
         Field weight1 = new NumericDocValuesField(WEIGHT_FIELD_NAME_1, 10 + i);
         Field weight2 = new NumericDocValuesField(WEIGHT_FIELD_NAME_2, 20 + i);
         Field weight3 = new NumericDocValuesField(WEIGHT_FIELD_NAME_3, 30 + i);
         Field contexts = new StoredField(CONTEXTS_FIELD_NAME, new BytesRef("ctx_" + i + "_0"));
         Document doc = new Document();
         doc.Add(field);
         doc.Add(payload);
         doc.Add(weight1);
         doc.Add(weight2);
         doc.Add(weight3);
         doc.Add(contexts);
         for (int j = 1; j < AtLeast(3); j++)
         {
             contexts.BytesValue = new BytesRef("ctx_" + i + "_" + j);
             doc.Add(contexts);
         }
         docs.Put(field.StringValue, doc);
     }
     return docs;
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:27,代码来源:DocumentValueSourceDictionaryTest.cs

示例10: DoRandom

        public virtual void DoRandom(int iter, bool ignoreCase)
        {
            CharArrayMap<int?> map = new CharArrayMap<int?>(TEST_VERSION_CURRENT, 1, ignoreCase);
            HashMap<string, int?> hmap = new HashMap<string, int?>();

            char[] key;
            for (int i = 0; i < iter; i++)
            {
                int len = Random().Next(5);
                key = new char[len];
                for (int j = 0; j < key.Length; j++)
                {
                    key[j] = (char)Random().Next(127);
                }
                string keyStr = new string(key);
                string hmapKey = ignoreCase ? keyStr.ToLower() : keyStr;

                int val = Random().Next();

                object o1 = map.Put(key, val);
                object o2 = hmap.Put(hmapKey, val);
                assertEquals(o1, o2);

                // add it again with the string method
                assertEquals(val, map.Put(keyStr, val));

                assertEquals(val, map.Get(key, 0, key.Length));
                assertEquals(val, map.Get(key));
                assertEquals(val, map.Get(keyStr));

                assertEquals(hmap.Count, map.size());
            }
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:33,代码来源:TestCharArrayMap.cs

示例11: GetFilesAsStringMap

 public static Map<string, string> GetFilesAsStringMap(string[] files)
 {
     HashMap<string, string> map = new HashMap<string, string>();
     foreach (string file in files)
     {
         map.Put(file, GetFileAsString(file));
     }
     return map;
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:9,代码来源:FileMaker.cs

示例12: getSideDrawerExamples

		private HashMap getSideDrawerExamples(){
			HashMap sideDrawerExamples = new HashMap();
			ArrayList result = new ArrayList();

			result.Add (new DrawerInitialSetupFragment());

			sideDrawerExamples.Put ("Init", result);

			return sideDrawerExamples;
		}
开发者ID:mardeniferreira,项目名称:Android-samples,代码行数:10,代码来源:SideDrawerExamples.cs

示例13: getCalendarExamples

        private HashMap getCalendarExamples()
        {
            HashMap calendarExamples = new HashMap();
            ArrayList result = new ArrayList();

            result.Add (new DrawerInitialSetupFragment());

            calendarExamples.Put ("Init", result);

            return calendarExamples;
        }
开发者ID:camlt,项目名称:Android-samples,代码行数:11,代码来源:SideDrawerExamples.cs

示例14: getDataFormExamples

        private HashMap getDataFormExamples()
        {
            HashMap dataFormExamples = new HashMap();
            ArrayList result = new ArrayList();

            result.Add (new DataFormGettingStartedFragment());
            result.Add (new DataFormFeaturesFragment());
            result.Add (new DataFormEditorsFragment());
            result.Add (new DataFormValidationFragment());
            dataFormExamples.Put ("Examples", result);

            return dataFormExamples;
        }
开发者ID:naveenpatel,项目名称:Android-samples,代码行数:13,代码来源:DataFormExamples.cs

示例15: TestCache

 public void TestCache() {
    Cache<String, String> cache = new HashCache<String, String>();
    Map<String, String> map = new HashMap<String, String>();
    for(int i = 0; i < LOAD_COUNT; i++) {
       String key = i.ToString();
       cache.Insert(key, key);
       map.Put(key, key);
    }
    for(int i = 0; i < LOAD_COUNT; i++) {
       String key = i.ToString();
       AssertEquals(cache.Fetch(key), key);
       AssertEquals(map.Get(key), cache.Fetch(key));
    }
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:14,代码来源:HashCacheTest.cs


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