CSE 2221 Study Guide - Final Guide: Substring

107 views3 pages

Document Summary

Standard has contracts for three methods: method (cid:862)clear(cid:863, method (cid:862)newinstance(cid:863, method (cid:862)transferfrom(cid:863) Sequencekernel has contracts for three methods: method (cid:862)add(cid:863, method (cid:862)remove(cid:863, method (cid:862)length(cid:863) Sequence has contracts for six other methods: method (cid:862)entry(cid:863, method (cid:862)replaceentry(cid:863, method (cid:862)append(cid:863, method (cid:862)flip(cid:863, method (cid:862)insert(cid:863, method (cid:862)extract(cid:863) The value of a sequence variable is modeled as a string of entries of type t. Formally: type sequence is modeled by string of t. Method (cid:862)add(cid:863) this = < > void add(int pos, t x: adds x at position pos of this, aliases: reference x, updates: this, requires, 0 <= pos and pos <= |this| Ensures: this = #this[0, pos) * * #this[pos, |#this|) T remove(int pos: removes and returns the entry at position pos of this, updates: this, requires, 0 <= pos and pos < |this| Ensures: this = #this[0, pos) * #this[pos+1, |#this|) and = #this[pos, pos+1) Method (cid:862)length(cid:863) int length(: reports the length of this.