Thread: data structures
View Single Post
  #2  
Old 03-19-2009, 08:40 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
That's a fairly good exercise. I remember taking a data structures course a few years ago, and we had to implement these things from scratch (sort of similar to what you did). Any chance this is inspired by such a course?

Just some things I noticed:
You could simplify the empty() function:
PHP Code:
public function empty() { 
  return 
front() == null;

And, the front() function just needs to be:
PHP Code:
public function front() { 
    return 
this.data[0]; 

I have a feeling you may have ported that bit over from Java or something from the way you're dealing with the null case.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote