The Artima Developer Community
Sponsored Link

Java Answers Forum
help! help!help!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
diqq

Posts: 3
Nickname: diqq
Registered: Feb, 2003

help! help!help! Posted: Feb 11, 2003 5:36 AM
Reply to this message Reply
Advertisement
I want to implement this interface Set using LinkedList and I no idea. can someone help me please.

Public interface Set{
public boolean insert(int i)
public boolean remove(int i)
public boolean member(int i)
}


public class A1 {
public static void main(String[] s1) {
long time1;
long time2;
for (int i =1; i < 5; i++) {
Set s = new LinkedSet();
int j = 0'
time1 = System.CurrentTimeMillis();
for (; j < i * 4000; j++) {
s.insert(j);
}
time2 = System.currentTimeMillis();
System.out.println("insertion of " + j + "elements takes "
+ (time2 - time1) + "milli seconds");

int k = 0;
time1 = System.currentTimeMillis()
for (; k < 1000; k++) {
s.isMember(((int) (Math.random() * i * 10000)) %j);
}
time2 = System.currentTimeMillis();
System.out.println("isMember with " + j + "elements takes "
+ (((double) (time2 -time1)) / k) + "milli seconds");
time1 = System.currentTimeMillis();
for (j = 0; j < i * 4000; j++) {
s.remove(j);
}
time2 = System.currentTimeMillis();
System.out.println("removal of " + j + "elements takes "
+ (time2 - time1) + "milli seconds");
}
}
}

Topic: anyone can explain this program? Previous Topic   Next Topic Topic: Review program/give input/help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use