KDTree Implementation in Java

I’m looking for a KDTree implementation in Java.
I’ve done a google search and the results seem pretty haphazard. There are actually lots of results, but they’re mostly just little one-off implementations, and I’d rather find something with a little more “production value”. Something like apache collections or the excellent C5 collection library for .NET. Something where I can see the public bug tracker and check to see when the last SVN commit happened. Also, in an ideal world, I’d find a nice well-designed API for spatial data structures, and the KDTree would be just one class in that library.

For this project, I’ll only be working in either 2 or 3 dimensions, and I’m mostly just interested in a good nearest-neighbors implementation.


In the book Algorithms in a Nutshell there is a kd tree implementation in java along with a few variations. All of the code is on and the book itself also walk you through the algorithm so you could build one yourself.


When’s the absolute latest you can call Page.ClientScript.RegisterClientScriptBlock?

I need to output some JavaScript in a WebControl based on some processing and some properties that the consumer can set, doing it on the load of the page will be to early.

When is the latest I can call RegisterClientScriptBlock and still have it output on the page?



or, if you override Render…. before calling “base.Render”


Tips for using Vim as a Java IDE? [closed]

I’m addicted to Vim, it’s now my de facto way of editing text files.

Being that it’s mainly a text editor and not an IDE, has anyone got tricks for me to make it easier when developing Java apps?

Some questions I have:

  • How do I invoke a maven task without leaving vi?
  • Can I get code completion?
  • How’s the syntax highlighting?

Anything else (other than “Don’t do it!”) that I should know about?


Some tips:

  • Make sure you use vim (vi improved). Linux and some versions of UNIX symlink vi to vim.
  • You can get code completion with eclim
  • Or you can get vi functionality within Eclipse with viPlugin
  • Syntax highlighting is great with vim
  • Vim has good support for writing little macros like running ant/maven builds

Have fun šŸ™‚


Javascript – how to replace a sub-string?

This is a simple one. I want to replace a sub-string with another sub-string on client-side using Javascript.

Original string is 'original READ ONLY'

I want to replace the 'READ ONLY' with 'READ WRITE'

Any quick answer please? Possibly with a javascript code snippet…


String.replace() is regexp-based; if you pass in a string as the first argument, the regexp made from it will not include the ā€˜gā€™ (global) flag. This option is essential if you want to replace all occurances of the search string (which is usually what you want).

An alternative non-regexp idiom for simple global string replace is:

function string_replace(haystack, find, sub) {
    return haystack.split(find).join(sub);

This is preferable where the find string may contain characters that have an unwanted special meaning in regexps.

Anyhow, either method is fine for the example in the question.


Java Generics (Wildcards)

I have a couple of questions about generic wildcards in Java:

  1. What is the difference between List<? extends T> and List<? super T>?

  2. What is a bounded wildcard and what is an unbounded wildcard?


In your first question, <? extends T> and <? super T> are examples of bounded wildcards. An unbounded wildcard looks like <?>, and basically means <? extends Object>. It loosely means the generic can be any type. A bounded wildcard (<? extends T> or <? super T>) places a restriction on the type by saying that it either has to extend a specific type (<? extends T> is known as an upper bound), or has to be an ancestor of a specific type (<? super T> is known as a lower bound).

The Java Tutorials have some pretty good explanations of generics in the articles Wildcards and More Fun with Wildcards.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 Ā© No Copyrights, All Questions are retrived from public domain..