Du bist hier: Snippet-Verzeichnis » Java (241)
Sprache:

2-dimensional orthogonal range searching-Point

Sprache: English
Programmiersprache: Java
Veröffentlicht von: menny [nicht registriert]
Letzte Änderung: 15.05.2006
Aufrufe: 1047


Beschreibung

This is a 2D object to use in 2-dimensional orthogonal range searching.with some fixing you can change the other classes to work with other 2D objects.

Code

1 import corejava.*; 2 /** 3 * this class represent a 2d point in the plane. <br> 4 */ 5 public class Point 6 { 7 // ***** private data ***** 8 private int[] p=new int[2]; 9 10 // ****** constructors ****** 11 public Point (int x1, int y1) 12 { 13 p[0] = x1; 14 p[1] = y1; 15 } 16 /** copy constructor */ 17 public Point (Point pp) 18 { 19 this.p[0] = pp.get(0); 20 this.p[1] = pp.get(1); 21 } 22 23 // ***** public methodes ***** 24 public int get(int i) 25 {return this.p[i];} 26 27 public void set(int i,int x) 28 { p[i]= x;} 29 30 public boolean equals (Point pp) 31 { 32 boolean eq=true; 33 int i=0; 34 while ((i<pp.length()) && eq) eq=(this.p[i]==pp.get(i)); 35 36 return eq; 37 } 38 public String toString() 39 { 40 return this.p[0]+" "+this.p[1]; 41 } 42 43 public int length() 44 { 45 return this.p.length; 46 } 47 48 public Object clone() 49 { 50 return new Point(this); 51 } 52 }// class Point

Ein Kommentar

1

hi, i need some help for downloading package corejava.*, how and where do i need to download? or does it already exist in the code? thank u

Montag, 1. Januar 0001 00:00:00 von azyati

Dieses Snippet kommentieren

Name *  

E-Mail (wird nicht angezeigt) *    

Website  

Kommentar *  

Sicherheitscode Sicherheitscode *    

RSS