12.05.2015 Views

type - David Vernon

type - David Vernon

type - David Vernon

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Object-Oriented Programming<br />

A Class for Sets - Application<br />

iset &iset::operator+=(int x)<br />

{ int i=binsearch(x, a, n), j; // !!<br />

if (i >= n || x != a[i]) // x is not yet in set?<br />

{ if (n % blocksize == 0)<br />

a = memoryspace(a, n, n+ blocksize);<br />

for (j=n; j>i; j--)<br />

a[j] = a[j-1];<br />

n++;<br />

a[i] = x;<br />

}<br />

return *this;<br />

}<br />

Copyright © 2007 <strong>David</strong> <strong>Vernon</strong> (www.vernon.eu)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!