Skip to content
This repository has been archived by the owner on May 27, 2019. It is now read-only.

abircb/Bag-ADT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bag ADT

A Bag data structure stores an unordered collection of values and allows multiple copies of the same value. Bags know how many occurrences (i.e., count) of each distinct value are in its collection. Adding a member increases the number of instances in the bag by one and removing a member decreases the number of instances in the bag by one. The member is deleted from the bag when it has no instances.

In this implementation of a Bag ADT, a bag is of a Comparable type and is homogenous. Its operations include:

  1. add()
  2. addWithOccurences()
  3. contains()
  4. remove()
  5. size()
  6. isEmpty()
  7. iterator()
  8. toString()
  9. removeAllCopies()
  10. subtract()

The Bag has been implemented using a dictionary(HashMap), a Linked list and an array.

Usage

The final build is a Maven project. Clone this repo and use your IDE to process the Maven .pom file. This may take a little while as the IDE will download all the dependencies needed. Experiment with the ADT and run main to understand its current functionality.