Array-based collection implementation: BagADT. java

Source: Internet
Author: User

/**
* @ Author Chen weibing
* @ Msn: cwbnig1982@hotmail.com
* @ E-mail: chenweibing1982@sohu.com
* @ CreateTime 2004-11-30
* @ Version: 1.0
*/
Package com. cwbnig. util;

Import java. util. Iterator;

Public interface BagADT
{
// Adds one element to this bag
Public void add (Object element );

// Remove and returns a random element from the bag
Public Object removeRandom () throws EmptyBagException;

// Removes and returns the specified element from this bag
Public Object remove (Object element) throws EmptyBagException, NoSuchElementException;

// Returns the union of this bag and the parameter
Public BagADT union (BagADT set );

// Returns true if this bag contains the parameter
Public boolean contains (Object target );

// Returns true if this bag and the parameter contain exacitly the same elements
Public boolean isEmpty ();

// Returns the number of elements in this set
Public int size ();

// Returns an iterator for the elements in this bag
Public Iterator iterator ();

// Returns a string representation of this bag
Public String toString ();
}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.