Difference between revisions of "Set Intersector Assignment"

From CSE231 Wiki
Jump to navigation Jump to search
Line 12: Line 12:
 
{{CodeToImplement|Intersections|intersectionOf|setintersector.group}}
 
{{CodeToImplement|Intersections|intersectionOf|setintersector.group}}
 
{{Sequential|public static <E> Set<E> intersectionOf(Set<E> first, Set<E>... rest)}}
 
{{Sequential|public static <E> Set<E> intersectionOf(Set<E> first, Set<E>... rest)}}
 +
 +
Note: the rest parameter leverages the [https://docs.oracle.com/javase/8/docs/technotes/guides/language/varargs.html varargs] feature.  You may treat this parameter as an array of Set<E>s.
  
 
=Testing=
 
=Testing=
 
{{TestSuite|_IntersectionTestSuite|setintersector.group}}
 
{{TestSuite|_IntersectionTestSuite|setintersector.group}}

Revision as of 18:35, 11 October 2022

Motivation

Performing the set intersection required by the Mutual Friends exercise can be a bit tricky. This group warmup will familiarize everyone with the provided [SetIntersector<E>] class.

Code To Investigate

SetIntersector<E>

class SetIntersector<E>

accept(friendIds)
currentIntersection()

Code To Implement

class: Intersections.java Java.png
methods: intersectionOf
package: setintersector.group
source folder: student/src/main/java

method: public static <E> Set<E> intersectionOf(Set<E> first, Set<E>... rest) Sequential.svg (sequential implementation only)

Note: the rest parameter leverages the varargs feature. You may treat this parameter as an array of Set<E>s.

Testing

class: _IntersectionTestSuite.java Junit.png
package: setintersector.group
source folder: testing/src/test/java