Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 08-28-2007, 04:17 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Hmm, nice Vash
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.