zoukankan      html  css  js  c++  java
  • 一天一个类,一点也不累 之 Set接口

    我们的口号是:一天一个类,一点也不累~~

    再次回忆一下集合相关的类图。

    官方API上这样介绍这个接口:

    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1 and e2 such that e1.equals(e2), and at most one null element. As implied by its name, this interface models the mathematical set abstraction.

    这个集合类不能容纳有复制品的元素,也就是不存在两个元素相等(equals),充其量存在一个NULL元素。  

    他提供的一些方法如下:

      int size();

    boolean isEmpty();

    boolean contains(Object o);

    Iterator<E> iterator();

     Object[] toArray();

    <T> T[] toArray(T[] a);

    boolean add(E e);

    boolean remove(Object o);

    boolean containsAll(Collection<?> c);

    boolean addAll(Collection<? extends E> c);

    boolean retainAll(Collection<?> c);

    boolean removeAll(Collection<?> c);

    void clear();

    boolean equals(Object o);

    int hashCode();

    而这些方法需要实现类来实现具体的操作。

  • 相关阅读:
    前端常用布局
    Vue, React, AngularJS, Angular2 我们对流行JavaScript框架们的选择
    使用vue-cli创建vue项目
    Null component Catalina
    初识MongoDB
    小米平板2 win10 MIUI互刷教程
    tomcat报错
    websocket
    前后端数据交互方法
    二叉排序树
  • 原文地址:https://www.cnblogs.com/plxx/p/4451624.html
Copyright © 2011-2022 走看看