CSE 2221 Study Guide - Final Guide: Foreach Loop, Iterator, Local Variable

140 views4 pages

Document Summary

The set component family allows you to manipulate finite sets of elements of any (arbitrary) type. Standard has contracts for three methods: method (cid:862)(cid:272)lear(cid:863, method (cid:862)(cid:374)e(cid:449)i(cid:374)sta(cid:374)(cid:272)e(cid:863, method (cid:862)tra(cid:374)sferfro(cid:373)(cid:863) Setkernel has contracts for five methods: method (cid:862)add(cid:863, method (cid:862)re(cid:373)o(cid:448)e(cid:863, method (cid:862)re(cid:373)o(cid:448)ea(cid:374)y(cid:863, method (cid:862)(cid:272)o(cid:374)tai(cid:374)s(cid:863, method (cid:862)size(cid:863) Set has contracts for two other methods: method (cid:862)add(cid:863, method (cid:862)re(cid:373)o(cid:448)e(cid:863) The value of a set variable is modeled as a (finite) set of elements of type t. Formally: type set is modeled by finite set of t. There is one constructor for each implementation class for set: as always, the name of the constructor is the name of the implementation class, the constructor has its own contract (which is in the kernel interface setkernel) Set si = new set1l<>(); si = { } Methods for set: all the methods for set are instance methods, i. e. , you call them as follows: s. methodname(arguments, where s is an initialized non-null variable of type set for some t.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents

Related Questions