ps4
Class StreetNumberSet

java.lang.Object
  extended by ps4.StreetNumberSet

public class StreetNumberSet
extends Object

Class overview to be written by student.


Constructor Summary
StreetNumberSet(String numbers)
          Creates a StreetNumberSet containing the numbers indicated in the argument.
 
Method Summary
 boolean contains(int i)
           
 boolean equals(Object other)
           
 int orderStatistic(int i)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreetNumberSet

public StreetNumberSet(String numbers)
Creates a StreetNumberSet containing the numbers indicated in the argument.

Requires:
numbers != null && numbers is a space-free comma-delimited list of zero or more disjoint parity ranges. Two parity ranges are disjoint if they share no elements. For example, 10-20 and 19-21 are disjoint: as one only contains even elements and the other contains odd. By contrast, 1-5 and 3-7 overlap, as they both contain 3 and 5.

A parity range is either a single nonnegative integer "n" or a hyphen-separated pair of nonnegative integers "m-n", where m and n have the same parity and m is no greater than n. A range m-n represents the set of all numbers from m to n, inclusive, which are the same parity as m and n.

For instance, legal arguments to this constructor include "", "5", "22,253", "3-101", and "1914-1918,1939-1945".

Method Detail

equals

public boolean equals(Object other)
Overrides:
equals in class Object
Returns:
true if other is a StreetNumberSet that contains the same numbers as this. In particular, this expression evaluates to true:
new StreetNumberSet("1-9").equals(new StreetNumberSet("1-3,5-9"))

contains

public boolean contains(int i)
Returns:
true iff i is in this

orderStatistic

public int orderStatistic(int i)
Returns:
the number of elements less than i in this