Monday, January 31, 2011

lecture #1

Josh Waxman
Cs 313 - Data Structures using Java

qccs313.blogspot.com

Data Structure?
Array -- dense list

Stack: what methods?
push, pop, top, empty, full
interface to the stack

what guts?
array of size 100 of int

interface is a contract
JStack

interface Stack {....}

class JStack implents Stack
{
...
}

foo(Stack<T> s)
{
    s.pop();
}

Try this:
write a Java method swap that takes
in two ints (or, Integers) and swaps them.

void swap(int a, int b)
void swap(Integer a, Integer b)

one hint as to why Java stinks.

deprecate a feature


C++:
if (x = 56)
{

}


?: operator

if (x == 6)
    7;
else
    6;

z = (x==6 ? 7 : 6);

x==6? y = 7: p = 67;
switch case
switch(x)
{
    case 1:

        break;
    case 2:
        ...
        ...
        ...
    case 9:
        ...
        ...
        ...
        break;
    default:
        ...
        ...
        ...
}

auto fall-through disallowed

No comments:

Post a Comment