View Single Post
  #1  
Old 08-28-2007, 06:47 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
setUnion(), setIntersection()

Here's two functions I made out of boredom from something I learned in about in math today.
PHP Code:
public function setUnion(set1set2) {
  
temp.set set1;
  for (
i=0i<set2.size(); i++) {
    if (!
set2[iin set1)
      
temp.set.add(set2[i]);
  }
  
temp.set.sortascending();
  return 
temp.set;
}
public function 
setIntersection(set1set2) {
  
temp.set NULL;
  for (
i=0i<set2.size(); i++) {
    if (
set2[iin set1)
      
temp.set.add(set2[i]);
  }
  
temp.set.sortascending();
  return 
temp.set;

If you didn't know, sets are pretty much arrays. setUnion(set1, set2) essentially combines two arrays, and setIntersection(set1, set2) makes an array of values that are in both sets (arrays).
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote