Author Topic: [Java] Enums with specified ordinals  (Read 6092 times)

0 Members and 1 Guest are viewing this topic.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: [Java] Enums with specified ordinals
« Reply #15 on: October 15, 2007, 09:01:15 pm »
An example of O(log(n)) would be a quicksort, because the number of iterations increases linearly as n increases proportionally. That is to say, each time you double the size of the input array, the run-time increases by a constant amount.

Quicksort is in the average case, in the worse case (which occurs when the list is already sorted).

An example of a algorithm is binary search.

Oops! I edited my post, and forgot to proof read it.

I don't know about the original problem, Camel.  I suppose you could do binary search instead of a linear search, if you make sure everything is in ascending order?  That's better than the O(n) you have there.  I guess that's what you were hinting at, though.  It's sort of an ugly problem, because you're going to have to muck something up.  You either do a search, which seems silly, or add a bunch of filler elements, which also seems silly.  I say you tell Java to fix the way enums work. :)

Since the packet IDs are mostly used, I will just fill in the gaps with SID_UNKNOWN_0x??s

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline while1

  • x86
  • Hero Member
  • *****
  • Posts: 1013
    • View Profile
Re: [Java] Enums with specified ordinals
« Reply #16 on: November 02, 2007, 08:42:39 pm »
Must... refrain... from making a big O joke.
I tend to edit my topics and replies frequently.

http://www.operationsmile.org

Offline Camel

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
    • BNU Bot
Re: [Java] Enums with specified ordinals
« Reply #17 on: November 05, 2007, 12:18:59 pm »
If you must bump old topics, you should at least have something to contribute.

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!