C++ for loop
1 minute ago, Spev said:I've never coded in Java but I've heard of for each. Basically it just goes through every element in the hash table? I guess that makes sense. I'm using separate chaining so my buckets are linked lists, and my hash table is a vector. So I guess it goes through every element (linked list) in my vector (hash table) and clears the entire list since it's an STL list it's pretty easy. Ok thanks if it's that simple than that explains it.
If you know C++, then you should be able to read Java code and know what's going on.
But yea, same thing in Java
For(Object temp : objects){
//do something
}
Where objects is an object (element in C++ terms) is inerrable. It goes through every Object class object in objects, refers each as temp in each iteration of the loop, and you do whatever you need to do with it.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now