Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Collection:
- [...]
- # Vérifie si un point appartient à la collection
- #
- # -?-
- # [Point] point: Point à tester
- # -!-
- # [bool]
- # -$-
- # [TypeError] ! -?-
- def appartient( self, point ):
- if( not isinstance( point, Point ) ):
- raise TypeError( '<point> n\'est pas une instance de [Point] !' )
- for pointCourant in self.liste:
- distance = point.distance( pointCourant )
- if( distance < 0.00001 ):
- return True
- return False
- # Trie la collection
- def trier( self ):
- resultat = list()
- liste = list( self.liste )
- while len( liste ):
- # Recherche du plus petit
- indiceMini = 0
- for indice in xrange( len( liste ) ):
- if( liste[indice].inf_ou_egal( liste[indiceMini] ) ):
- indiceMini = indice
- resultat.append( liste.pop( indiceMini ) )
- self.liste = resultat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement