Click here to Skip to main content
15,905,028 members
Home / Discussions / Java
   

Java

 
GeneralRe: Call Class Pin
moxwose18-Nov-10 22:53
moxwose18-Nov-10 22:53 
GeneralRe: Call Class Pin
David Skelly19-Nov-10 1:56
David Skelly19-Nov-10 1:56 
GeneralRe: Call Class Pin
moxwose19-Nov-10 2:31
moxwose19-Nov-10 2:31 
QuestionJava interaction with scanner,web cam, epabx,pbx like hardwares Pin
Alok Sharma ji10-Nov-10 23:57
Alok Sharma ji10-Nov-10 23:57 
AnswerRe: Java interaction with scanner,web cam, epabx,pbx like hardwares Pin
TorstenH.11-Nov-10 0:00
TorstenH.11-Nov-10 0:00 
GeneralRe: Java interaction with scanner,web cam, epabx,pbx like hardwares Pin
Alok Sharma ji12-Nov-10 4:08
Alok Sharma ji12-Nov-10 4:08 
GeneralRe: Java interaction with scanner,web cam, epabx,pbx like hardwares Pin
TorstenH.12-Nov-10 5:15
TorstenH.12-Nov-10 5:15 
Questionsearch logic failed Pin
kingnking10-Nov-10 16:40
kingnking10-Nov-10 16:40 
guys please tell me why my code for searching in hash keep failing... please help me.. i don't know where i get it wrong
this is the code

	private static void search(Hashtable<Long, ArrayList<Integer>> sHash) {
		NumberFormat formatter = NumberFormat.getInstance();
		System.out.println("\tBegin searching process...");
		Hashtable<Long, ArrayList<DataPoint>> resultHash = new Hashtable<Long, ArrayList<DataPoint>>(10);
		for (Long hash : sHash.keySet()) {
			ArrayList<Integer> sTimes = sHash.get(hash);
			ArrayList<SongTime> mHash = DBUtil.searchHash(hash);
			for (SongTime st : mHash) {
				ArrayList<DataPoint> al = resultHash.get(st.songId);
				if (null == al)
					al = new ArrayList<DataPoint>();
				for (Integer time : sTimes) {
					DataPoint dp = new DataPoint();
					dp.hash = hash;
					dp.songTimeId = st.timeId;
					dp.timeId = time;
					al.add(dp);
				}
				resultHash.put(st.songId, al);
			}
		}

		System.out.println("\tBegin matching process...");
		//			double topP = 0;
		int top = 0;
		int d = 0;
		long id = 0;
		for (Long songId : resultHash.keySet()) {
			String songName = DBUtil.getSongName(songId);
			ArrayList<DataPoint> al = resultHash.get(songId);
			Hashtable<Integer, Integer> ht = new Hashtable<Integer, Integer>();
			for (DataPoint dp : al) {
				//					System.out.println("\t\t" + dp.diff());
				int diff = dp.diff();
				if (diff >= 0) {
					Integer count = ht.get(diff);
					if (null == count)
						count = 0;
					ht.put(diff, new Integer(count + 1));
				}
			}

			int sCount = 0;
			for (Integer diff : ht.keySet()) {
				int count = ht.get(diff);
				//					double per = (double)count / (double)al.size() * 100.0;
				if (count > 1) {
					if ( count > top ) {
						//						if ( per > topP ) {
						top = count;
						id = songId;
						d = diff;
					}
					if ( count > sCount ) {
						sCount = count;
						d = diff;
					}
					//						System.out.println("\t\t\t" + diff + "\t-> " + count);
				}
			}
			double percentage = ( (double)sCount / (double)sHash.size() * 100.0 ); 
			System.out.println("\t\t" + formatter.format(percentage) + " %\t-> " + 
					sCount + " / " + al.size() + " / " + sHash.size() + " -> " + d + " ( " + songName + " )");
			//				System.out.println("\t\t\tHighest Match Count : " + top);
		}
		System.out.println("\tFinal : " + DBUtil.getSongName(id));
		System.out.println();
	}

}

AnswerRe: search logic failed Pin
David Skelly10-Nov-10 22:31
David Skelly10-Nov-10 22:31 
AnswerRe: search logic failed Pin
TorstenH.11-Nov-10 0:03
TorstenH.11-Nov-10 0:03 
GeneralRe: search logic failed Pin
kingnking13-Nov-10 3:50
kingnking13-Nov-10 3:50 
GeneralRe: search logic failed Pin
TorstenH.13-Nov-10 5:01
TorstenH.13-Nov-10 5:01 
QuestioneHarmony like Platform Pin
Jason Turp10-Nov-10 10:47
Jason Turp10-Nov-10 10:47 
AnswerRe: eHarmony like Platform Pin
David Skelly10-Nov-10 22:29
David Skelly10-Nov-10 22:29 
Questionapplet image loading problem Pin
ekba899-Nov-10 9:36
ekba899-Nov-10 9:36 
AnswerRe: applet image loading problem Pin
Nagy Vilmos9-Nov-10 23:16
professionalNagy Vilmos9-Nov-10 23:16 
GeneralRe: applet image loading problem Pin
ekba8910-Nov-10 11:15
ekba8910-Nov-10 11:15 
GeneralRe: applet image loading problem Pin
ekba8912-Nov-10 11:30
ekba8912-Nov-10 11:30 
AnswerRe: applet image loading problem Pin
ekba8912-Nov-10 12:49
ekba8912-Nov-10 12:49 
Questionwhy can't I figure out array input Pin
LORDA127-Nov-10 23:08
LORDA127-Nov-10 23:08 
AnswerRe: why can't I figure out array input Pin
Cedric Moonen7-Nov-10 23:27
Cedric Moonen7-Nov-10 23:27 
GeneralRe: why can't I figure out array input Pin
LORDA127-Nov-10 23:41
LORDA127-Nov-10 23:41 
GeneralRe: why can't I figure out array input Pin
Cedric Moonen7-Nov-10 23:54
Cedric Moonen7-Nov-10 23:54 
AnswerRe: why can't I figure out array input Pin
Luc Pattyn8-Nov-10 2:01
sitebuilderLuc Pattyn8-Nov-10 2:01 
AnswerRe: why can't I figure out array input [modified] Pin
Nagy Vilmos8-Nov-10 2:55
professionalNagy Vilmos8-Nov-10 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.