+/EE312
software design
git clone https://git.julia.blue/+/EE312
7bf8175
master
1#ifndef _Set_h 2#define _Set_h 1 3 4struct Set { 5int * elements ; 6int len ; 7// int capacity; // NOTE: amortized doubling does not improve the time complexity for these problems 8/* in fact, you can safely ignore capacity entirely. I'm including it here just in case some 9* students feel more comfortable tracking the array size and the number of elements independently 10* REPEATNG: You do not need to to implement amortized doubling in order to achieve the time-complexity 11* bounds for this problem. You can achieve all the time complexity bounds even when 12* capacity is ignored (i.e., your design can assume capacity == len). 13*/ 14}; 15 16/* creation, assignment and destruction functions */ 17void createSingletonSet (Set * self ,int x );// construct a set containing only the element x 18void createEmptySet (Set * self );// construct a set containing no elements 19void createCopySet (Set * self ,const Set * other );// construct a new set that has the same elements as other 20void assignSet (Set * self ,const Set * other );// replace the elements in this set with the elements of other 21void destroySet (Set * self ); 22 23/* predicate functions */ 24bool isMemberSet (const Set * self ,int x );// return true iff x is an element in the set 25bool isEmptySet (const Set * self );// return true iff the set contains zero elements 26bool isEqualToSet (const Set * self ,const Set * other );// return true iff this and other 27// contain the same elements 28bool isSubsetOf (const Set * self ,const Set * other );// return true if all of the elements 29// self are also elements of other 30// NOTE: for any set, x, x is a subset 31// of itself. 32/* printing */ 33void displaySet (const Set * self ); 34 35/* scalar manipulation functions */ 36void insertSet (Set * self ,int x );// insert x into this set. does nothing if 37// x is already in the set 38void removeSet (Set * self ,int x );// remove x from this set. does nothing if 39// x is not in the set 40 41/* manipulations with sets */ 42void unionInSet (Set * self ,const Set * other );// replace the elements of self with self union other 43void intersectFromSet (Set * self ,const Set * other );// replace the elements of self with self intersection other 44void subtractFromSet (Set * self ,const Set * other );// replace the elements of self with self minus other 45 46#endif /* _Set_h */