subject

A Set is an abstract data type (ADT) that stores unique elements. It provides the following operations: a. void add(E element)- adds an element to the set. If the same element (according to equals(Object)) is already in the set, the new element is ignored . Note: this is different from how Maps work!

b. void remove(E element)- removes an element from the set.

c. boolean contains(E element)- returns true if the element is in the set, and false otherwise.

d. int size() - returns the number of elements stored in the set.

e. Iterator iterator() - returns an iterator that can be used to iterate over the elements in the set. This is necessary to enable a data structure to work with Java's for loops.

You can think of a Set like a Map that only stores keys (and no values). In fact, a Set can be implemented using a Map - the elements of the set are keys in the Map (the values in the Map do not matter and can be null or some other placeholder value).

Create a generic Set interface that provides the methods described above.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. a company wants to use online methods to target more customers. it decides to conduct a market research by collecting the data of a few customers with their consent. they want to track data of the sites that their customers frequently visit. which software can the company? a. spyware b. bots c. adware d. trojan horse e. rootkits
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
You know the right answer?
A Set is an abstract data type (ADT) that stores unique elements. It provides the following operatio...
Questions
question
Mathematics, 25.06.2019 02:30
question
Mathematics, 25.06.2019 02:40
question
Mathematics, 25.06.2019 02:40
question
Social Studies, 25.06.2019 02:40
question
Social Studies, 25.06.2019 02:40
Questions on the website: 13722367