黄色网址大全免费-黄色网址你懂得-黄色网址你懂的-黄色网址有那些-免费超爽视频-免费大片黄国产在线观看

Guava教程

Guava Multiset接口

Multiset接口擴展設置有重復的元素,并提供了各種實用的方法來處理這樣的元素在集合中出現。

接口聲明

以下是com.google.common.collect.Multiset<E>接口的聲明:

@GwtCompatible
public interface Multiset<E>
? ?extends Collection<E>

接口方法

方法繼承

此接口繼承從以下接口方法: java.util.Collection

Multiset 示例

使用所選擇的編輯器創建下面的java程序,比如說 C:/> Guava
GuavaTester.java

import java.util.Iterator;
import java.util.Set;

import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;

public class GuavaTester {

   public static void main(String args[]){
      //create a multiset collection
      Multiset<String> multiset = HashMultiset.create();
      multiset.add("a");
      multiset.add("b");
      multiset.add("c");
      multiset.add("d");
      multiset.add("a");
      multiset.add("b");
      multiset.add("c");
      multiset.add("b");
      multiset.add("b");
      multiset.add("b");
      //print the occurrence of an element
      System.out.println("Occurrence of 'b' : "+multiset.count("b"));
      //print the total size of the multiset
      System.out.println("Total Size : "+multiset.size());
      //get the distinct elements of the multiset as set
      Set<String> set = multiset.elementSet();
      //display the elements of the set
      System.out.println("Set [");
      for (String s : set) {			
         System.out.println(s);		    
      }
      System.out.println("]");
      //display all the elements of the multiset using iterator
      Iterator<String> iterator  = multiset.iterator();
      System.out.println("MultiSet [");
      while(iterator.hasNext()){
         System.out.println(iterator.next());
      }
      System.out.println("]");		
      //display the distinct elements of the multiset with their occurrence count
      System.out.println("MultiSet [");
      for (Multiset.Entry<String> entry : multiset.entrySet())
      {
         System.out.println("Element: "+entry.getElement() +", Occurrence(s): " + entry.getCount());		    
      }
      System.out.println("]");		

      //remove extra occurrences 
      multiset.remove("b",2);
      //print the occurrence of an element
      System.out.println("Occurence of 'b' : "+multiset.count("b"));
   }	
}

驗證結果

使用javac編譯器編譯如下類

C:\Guava>javac GuavaTester.java

現在運行GuavaTester看到的結果

C:\Guava>java GuavaTester

看到結果 

Occurence of 'b' : 5
Total Size : 10
Set [
d
b
c
a
]
MultiSet [
d
b
b
b
b
b
c
c
a
a
]
MultiSet [
Element: d, Occurence(s): 1
Element: b, Occurence(s): 5
Element: c, Occurence(s): 2
Element: a, Occurence(s): 2
]
Occurence of 'b' : 3

 

 

 

 

轉載自并發編程網-ifeve.com

全部教程
主站蜘蛛池模板: 不卡一级aaa全黄毛片 | 最近免费字幕高清在线观看 | 国产精品久久久天天影视香蕉 | 小明看片| 夜夜揉揉日日人人视频 | 手机在线精品视频每日更新 | 亚洲国产一区二区三区 | 男男1v1高h猛烈做哭bl强制 | 日韩午夜在线观看 | 在线 | 一区二区三区四区 | 国产 日韩 欧美 在线 | 最近2019免费中文字幕8 | 国产高清不卡一区二区三区 | 最黄毛片 | 成人在色线视频在线观看免费大全 | 日韩亚洲欧美性感视频影片免费看 | 黄网站色年片在线观看 | 国产观看精品一区二区三区 | 韩国成人理伦片免费 | 在线观看免费毛片 | 男女边摸边吃奶边做视频在线 | 欧美日韩一区二区视频免费看 | 日韩黄色三级视频 | 性欧美xxxx视频在线观看 | 小明中文字幕 | 黄网站免费在线观看 | 欧美日韩一二区 | 国产在线a视频 | 在线观看一夜七次郎国产 | 国产欧美在线不卡 | 亚洲欧美片 | 国产综合视频在线 | 羞羞视频免费 | 欧美久久一区二区 | 欧美人在线一区二区三区 | 手机在线国产精品 | 色综合五月激情综合色一区 | 视频成人永久免费视频 | xxx欧洲| 日韩一级影院 | 日韩一区二区三区不卡 |