473,494 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

HELP - Fast algorithm for Comparator implementation

[I posted this to comp.programming but realised later that
comp.lang.java is probably more appropriate - apologies if you are
reading this for the 2nd time]

Hi. I need an implementation of java.util.Comparator with the
following features:

1. Given a (mutable) java.util.List instance of unspecified size at
construction time.

2. That List instance ALWAYS contains the objects it will be asked to
compare.

3. The compare(Object,Object) method should return its result based on
the relative positions of the specified objects in that List instance
- e.g. if o1 is at index 5 and o2 is at index 19, then compare(o1,o2)
should return a negative integer.

4. The compare(..) method will be called very often, so I am looking
for the most efficient algorithm possible.

5. It may be possible to be notified by that List instance whenever
its contents change, which would be relatively infrequent compared to
calls to the compare(..) method.

I appeal to all you clever people out there for a fast, elegant
solution to this problem. Let me say in advance I am extremely
grateful for your efforts!

Cheers.
Jul 17 '05 #1
0 3009

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2508
by: Herman | last post by:
Hi everyone, I'm implementing Dijkstra's algorithm for a class project, and I'm having trouble compiling the class that runs the algorithm. All of the other files compile fine except for this one....
7
3991
by: Christopher Jeris | last post by:
I am relatively new to JavaScript, though not to programming, and I'm having trouble finding the idiomatic JS solution to the following problem. I have a table with (say) fields f1, f2, f3. I...
7
2608
by: JN | last post by:
Hello. Sorry about the length of this post. I am trying to implement a hash table for my chess program, and decided to try using the VC++ . NET (Dinkumware) version of hash_map. The role of the...
2
1985
by: Steven T. Hatton | last post by:
While thunbing through _C++ Templates, The Complete Guide_ (reckon I aught to read it?) I came across a discussion of using templates to "unroll" loops. I thought that looked like a good idea, so...
17
2642
by: Trent Buck | last post by:
The fourth argument is a comparator that returns `an integer less than, equal to, or greater than zero' depending on the ordering of its arguments. If I don't care about the order and simply...
2
1572
by: Peter Schmitz | last post by:
Hi again, I just need to write the following function to search in a binary buffer for a given pattern: BOOL CheckBufferForPattern(BYTE *buffer,int bufferlen,BYTE *pattern, int patternlen,...
23
2058
by: Rogers | last post by:
I want to compare strings of numbers that have a circular boundary condition. This means that the string is arranged in a loop without an end-of-string. The comparaison of two strings now...
3
1895
by: jesper | last post by:
I would like some feedback on this. A while back I was trying my hand at some pathfinding for a small game I was making. I did not know anything about it so I read some stuff and came up with the...
19
5374
by: Juha Nieminen | last post by:
If I'm not completely mistaken, the only reason why std::list::size() may be (and usually is) a linear-time operation is because they want std::list::splice() to be a constant-time operation, and...
0
6989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7367
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
644
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.