Beispiel #1
0
 // get a person from the pool
 public Person getPerson()
 {
     Person person = null;
     if (_persons.Count > 0)
     {
         person = _persons.First();
         _persons.Remove(person);
     }
     else
     {
         // if the pool is empty, make a new person and refill the pool
         person = new Person();
         refillPersonPool();
     }
     // return the reference to the person
     return person;
 }
Beispiel #2
0
 // returns a person to the pool
 public void returnPerson(Person person)
 {
     // objects in a pool may not have any references to or from them exept the reference from the pool
     person.Sever();
     _persons.Add(person);
 }