大战熟女丰满人妻av-荡女精品导航-岛国aaaa级午夜福利片-岛国av动作片在线观看-岛国av无码免费无禁网站-岛国大片激情做爰视频

Guava教程

Guava Multiset接口

Multiset接口擴(kuò)展設(shè)置有重復(fù)的元素,并提供了各種實(shí)用的方法來處理這樣的元素在集合中出現(xiàn)。

接口聲明

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

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

接口方法

方法繼承

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

Multiset 示例

使用所選擇的編輯器創(chuàng)建下面的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"));
   }	
}

驗(yàn)證結(jié)果

使用javac編譯器編譯如下類

C:\Guava>javac GuavaTester.java

現(xiàn)在運(yùn)行GuavaTester看到的結(jié)果

C:\Guava>java GuavaTester

看到結(jié)果 

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

 

 

 

 

轉(zhuǎn)載自并發(fā)編程網(wǎng)-ifeve.com

全部教程
主站蜘蛛池模板: 欧美日韩亚洲精品国产色 | 99久热这里只有精品免费 | 亚州色吧 | 草草影院1 | a在线视频免费观看 | 农村女人十八毛片a级毛片 农村三级孕妇视频在线 | 亚洲国产中文在线 | 日日碰狠狠添天天爽对白 | 欧美aav| 福利免费在线 | 网友自拍视频悠悠在线 | 久久久久久九九 | 色视频一区 | 免费人成激情视频在线观看冫 | 一级毛片私人影院老司机 | 中文字幕在线看视频一区二区三区 | 天天视频入口 | 四虎网址 | 日韩不卡一区二区三区 | 玖玖爱精品 | 黄色高清在线观看 | 日本黄色免费网址 | 久久在线视频免费观看 | 真人视频一级毛片 | 久久精品国产免费 | 香蕉视频在线观看网站 | 亚洲国产天堂久久精品网 | 国产精品视频偷伦精品视频 | 成人 亚洲 | 国产精品欧美亚洲韩国日本久久 | 特黄特级毛片免费视 | 开心激情四房 | 综合色吧 | 午夜伦情电午夜伦情影院 | 久久青草91线频免费观看 | 亚洲精品国产精品国自产观看 | 97视频| 奶交性视频欧美 | 99热这里只有精品久久免费 | 亚洲综合激情六月婷婷在线观看 | 高清中文字幕视频在线播 |