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


C# CharArraySet.size方法代码示例

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


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

示例1: CheckSet

 private void CheckSet(CharArraySet wordset)
 {
     assertEquals(3, wordset.size());
     assertTrue(wordset.contains("ONE")); // case is not modified
     assertTrue(wordset.contains("two")); // surrounding whitespace is removed
     assertTrue(wordset.contains("three"));
     assertFalse(wordset.contains("four"));
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:8,代码来源:TestWordlistLoader.cs

示例2: testClear

 public virtual void testClear()
 {
     CharArraySet set = new CharArraySet(TEST_VERSION_CURRENT, 10,true);
     set.addAll(TEST_STOP_WORDS);
     assertEquals("Not all words added", TEST_STOP_WORDS.Length, set.size());
     set.clear();
     assertEquals("not empty", 0, set.size());
     for (int i = 0;i < TEST_STOP_WORDS.Length;i++)
     {
       assertFalse(set.contains(TEST_STOP_WORDS[i]));
     }
     set.addAll(TEST_STOP_WORDS);
     assertEquals("Not all words added", TEST_STOP_WORDS.Length, set.size());
     for (int i = 0;i < TEST_STOP_WORDS.Length;i++)
     {
       assertTrue(set.contains(TEST_STOP_WORDS[i]));
     }
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:18,代码来源:TestCharArraySet.cs

示例3: TestRehash

 public virtual void TestRehash()
 {
     CharArraySet cas = new CharArraySet(TEST_VERSION_CURRENT, 0, true);
     for (int i = 0; i < TEST_STOP_WORDS.Length; i++)
     {
         cas.Add(TEST_STOP_WORDS[i]);
     }
     assertEquals(TEST_STOP_WORDS.Length, cas.size());
     for (int i = 0; i < TEST_STOP_WORDS.Length; i++)
     {
         assertTrue(cas.Contains(TEST_STOP_WORDS[i]));
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:13,代码来源:TestCharArraySet.cs

示例4: testCopyCharArraySet

        /// <summary>
        /// Test the static #copy() function with a CharArraySet as a source
        /// </summary>
        public virtual void testCopyCharArraySet()
        {
            CharArraySet setIngoreCase = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
            CharArraySet setCaseSensitive = new CharArraySet(TEST_VERSION_CURRENT, 10, false);

            IList<string> stopwords = TEST_STOP_WORDS;
            IList<string> stopwordsUpper = new List<string>();
            foreach (string @string in stopwords)
            {
              stopwordsUpper.Add(@string.ToUpper(Locale.ROOT));
            }
            setIngoreCase.addAll(TEST_STOP_WORDS);
            setIngoreCase.add(Convert.ToInt32(1));
            setCaseSensitive.addAll(TEST_STOP_WORDS);
            setCaseSensitive.add(Convert.ToInt32(1));

            CharArraySet copy = CharArraySet.copy(TEST_VERSION_CURRENT, setIngoreCase);
            CharArraySet copyCaseSens = CharArraySet.copy(TEST_VERSION_CURRENT, setCaseSensitive);

            assertEquals(setIngoreCase.size(), copy.size());
            assertEquals(setCaseSensitive.size(), copy.size());

            assertTrue(copy.containsAll(stopwords));
            assertTrue(copy.containsAll(stopwordsUpper));
            assertTrue(copyCaseSens.containsAll(stopwords));
            foreach (string @string in stopwordsUpper)
            {
              assertFalse(copyCaseSens.contains(@string));
            }
            // test adding terms to the copy
            IList<string> newWords = new List<string>();
            foreach (string @string in stopwords)
            {
              newWords.Add(@string + "_1");
            }
            copy.addAll(newWords);

            assertTrue(copy.containsAll(stopwords));
            assertTrue(copy.containsAll(stopwordsUpper));
            assertTrue(copy.containsAll(newWords));
            // new added terms are not in the source set
            foreach (string @string in newWords)
            {
              assertFalse(setIngoreCase.contains(@string));
              assertFalse(setCaseSensitive.contains(@string));

            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:51,代码来源:TestCharArraySet.cs

示例5: testUnmodifiableSet

        public virtual void testUnmodifiableSet()
        {
            CharArraySet set = new CharArraySet(TEST_VERSION_CURRENT, 10,true);
            set.addAll(TEST_STOP_WORDS);
            set.add(Convert.ToInt32(1));
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final int size = set.size();
            int size = set.size();
            set = CharArraySet.unmodifiableSet(set);
            assertEquals("Set size changed due to unmodifiableSet call", size, set.size());
            foreach (string stopword in TEST_STOP_WORDS)
            {
              assertTrue(set.contains(stopword));
            }
            assertTrue(set.contains(Convert.ToInt32(1)));
            assertTrue(set.contains("1"));
            assertTrue(set.contains(new char[]{'1'}));

            try
            {
              CharArraySet.unmodifiableSet(null);
              fail("can not make null unmodifiable");
            }
            catch (System.NullReferenceException)
            {
              // expected
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:28,代码来源:TestCharArraySet.cs

示例6: testModifyOnUnmodifiable

        public virtual void testModifyOnUnmodifiable()
        {
            CharArraySet set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
            set.addAll(TEST_STOP_WORDS);
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final int size = set.size();
            int size = set.size();
            set = CharArraySet.unmodifiableSet(set);
            assertEquals("Set size changed due to unmodifiableSet call", size, set.size());
            string NOT_IN_SET = "SirGallahad";
            assertFalse("Test String already exists in set", set.contains(NOT_IN_SET));

            try
            {
              set.add(NOT_IN_SET.ToCharArray());
              fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
              // expected
              assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
              assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
              set.add(NOT_IN_SET);
              fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
              // expected
              assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
              assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
              set.add(new StringBuilder(NOT_IN_SET));
              fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
              // expected
              assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
              assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
              set.clear();
              fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
              // expected
              assertFalse("Changed unmodifiable set", set.contains(NOT_IN_SET));
              assertEquals("Size of unmodifiable set has changed", size, set.size());
            }
            try
            {
              set.add((object) NOT_IN_SET);
              fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
              // expected
              assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
              assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            // This test was changed in 3.1, as a contains() call on the given Collection using the "correct" iterator's
            // current key (now a char[]) on a Set<String> would not hit any element of the CAS and therefor never call
            // remove() on the iterator
            try
            {
              set.removeAll(new CharArraySet(TEST_VERSION_CURRENT, TEST_STOP_WORDS, true));
              fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
              // expected
              assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
              set.retainAll(new CharArraySet(TEST_VERSION_CURRENT, NOT_IN_SET, true));
              fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
              // expected
              assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
              set.addAll(NOT_IN_SET);
              fail("Modified unmodifiable set");
//.........这里部分代码省略.........
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:101,代码来源:TestCharArraySet.cs

示例7: PatternAnalyzer

	  /// <summary>
	  /// Constructs a new instance with the given parameters.
	  /// </summary>
	  /// <param name="matchVersion"> currently does nothing </param>
	  /// <param name="pattern">
	  ///            a regular expression delimiting tokens </param>
	  /// <param name="toLowerCase">
	  ///            if <code>true</code> returns tokens after applying
	  ///            String.toLowerCase() </param>
	  /// <param name="stopWords">
	  ///            if non-null, ignores all tokens that are contained in the
	  ///            given stop set (after previously having applied toLowerCase()
	  ///            if applicable). For example, created via
	  ///            <seealso cref="StopFilter#makeStopSet(Version, String[])"/>and/or
	  ///            <seealso cref="WordlistLoader"/>as in
	  ///            <code>WordlistLoader.getWordSet(new File("samples/fulltext/stopwords.txt")</code>
	  ///            or <a href="http://www.unine.ch/info/clef/">other stop words
	  ///            lists </a>. </param>
	  public PatternAnalyzer(Version matchVersion, Pattern pattern, bool toLowerCase, CharArraySet stopWords)
	  {
		if (pattern == null)
		{
		  throw new System.ArgumentException("pattern must not be null");
		}

		if (eqPattern(NON_WORD_PATTERN, pattern))
		{
			pattern = NON_WORD_PATTERN;
		}
		else if (eqPattern(WHITESPACE_PATTERN, pattern))
		{
			pattern = WHITESPACE_PATTERN;
		}

		if (stopWords != null && stopWords.size() == 0)
		{
			stopWords = null;
		}

		this.pattern = pattern;
		this.toLowerCase = toLowerCase;
		this.stopWords = stopWords;
		this.matchVersion = matchVersion;
	  }
开发者ID:paulirwin,项目名称:lucene.net,代码行数:44,代码来源:PatternAnalyzer.cs

示例8: TestClear

 public virtual void TestClear()
 {
     var set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
     set.AddAll(TEST_STOP_WORDS);
     assertEquals("Not all words added", TEST_STOP_WORDS.Length, set.size());
     set.Clear();
     assertEquals("not empty", 0, set.size());
     for (var i = 0; i < TEST_STOP_WORDS.Length; i++)
     {
         assertFalse(set.Contains(TEST_STOP_WORDS[i]));
     }
     set.AddAll(TEST_STOP_WORDS);
     assertEquals("Not all words added", TEST_STOP_WORDS.Length, set.size());
     for (var i = 0; i < TEST_STOP_WORDS.Length; i++)
     {
         assertTrue("Set doesn't contain " + TEST_STOP_WORDS[i], set.Contains(TEST_STOP_WORDS[i]));
     }
 }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:18,代码来源:TestCharArraySet.cs

示例9: TestUnmodifiableSet

        public virtual void TestUnmodifiableSet()
        {
            var set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
            set.AddAll(TEST_STOP_WORDS);
            set.Add(Convert.ToInt32(1));
            int size = set.size();
            set = CharArraySet.UnmodifiableSet(set);
            assertEquals("Set size changed due to unmodifiableSet call", size, set.size());
            foreach (var stopword in TEST_STOP_WORDS)
            {
                assertTrue(set.Contains(stopword));
            }
            assertTrue(set.Contains(Convert.ToInt32(1)));
            assertTrue(set.Contains("1"));
            assertTrue(set.Contains(new[] { '1' }));

            try
            {
                CharArraySet.UnmodifiableSet(null);
                fail("can not make null unmodifiable");
            }
            catch (System.ArgumentNullException) // NOTE: In .NET we throw an ArgumentExcpetion, not a NullReferenceExeption
            {
                // expected
            }
        }
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:26,代码来源:TestCharArraySet.cs

示例10: TestModifyOnUnmodifiable

        public virtual void TestModifyOnUnmodifiable()
        {
            CharArraySet set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
            set.AddAll(TEST_STOP_WORDS);
            int size = set.size();
            set = CharArraySet.UnmodifiableSet(set);
            assertEquals("Set size changed due to unmodifiableSet call", size, set.size());
            string NOT_IN_SET = "SirGallahad";
            assertFalse("Test String already exists in set", set.Contains(NOT_IN_SET));

            try
            {
                set.Add(NOT_IN_SET.ToCharArray());
                fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
                // expected
                assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
                assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
                set.add(NOT_IN_SET);
                fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
                // expected
                assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
                assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
                set.Add(new StringBuilder(NOT_IN_SET));
                fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
                // expected
                assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
                assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            try
            {
                set.clear();
                fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
                // expected
                assertFalse("Changed unmodifiable set", set.contains(NOT_IN_SET));
                assertEquals("Size of unmodifiable set has changed", size, set.size());
            }
            try
            {
                set.add(NOT_IN_SET);
                fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
                // expected
                assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
                assertEquals("Size of unmodifiable set has changed", size, set.size());
            }

            // NOTE: This results in a StackOverflow exception. Since this is not a public member of CharArraySet,
            // but an extension method for the test fixture (which apparently has a bug), this test is non-critical
            //// This test was changed in 3.1, as a contains() call on the given Collection using the "correct" iterator's
            //// current key (now a char[]) on a Set<String> would not hit any element of the CAS and therefor never call
            //// remove() on the iterator
            //try
            //{
            //    set.removeAll(new CharArraySet(TEST_VERSION_CURRENT, TEST_STOP_WORDS, true));
            //    fail("Modified unmodifiable set");
            //}
            //catch (System.NotSupportedException)
            //{
            //    // expected
            //    assertEquals("Size of unmodifiable set has changed", size, set.size());
            //}

            #region Added for better .NET support
            // This test was added for .NET to check the Remove method, since the extension method
            // above fails to execute.
            try
            {
#pragma warning disable 612, 618
                set.Remove(TEST_STOP_WORDS[0]);
#pragma warning restore 612, 618
                fail("Modified unmodifiable set");
            }
            catch (System.NotSupportedException)
            {
                // expected
                assertEquals("Size of unmodifiable set has changed", size, set.size());
            }
//.........这里部分代码省略.........
开发者ID:ChristopherHaws,项目名称:lucenenet,代码行数:101,代码来源:TestCharArraySet.cs


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