Looking for a real "BitSet"

Hi all,
I'm looking for an efficient set implementation based on bit vectors. BitSet doesn't support the set interface. EnumSet requires you to know the set of elements at compile time, which I don't.
I guess I could subclass BitSet, implementing the Set interface, but I was hoping someone could point me toward an existing solution.
Thanks!
David

I didn't find anything in the Jakarta collections. So I went ahead and implemented a "FixedSet" which is like EnumSet but is based on a collection that specifies the universe at runtime, instead of an enum that specifies the universe at compile time.
For example:
HashSet<String> universe = new HashSet<String>;
universe.add("a");
universe.add("b");
universe.add("c");
universe.add("d");
universe.add("e");
// Fast bit vector based implementation
FixedSet<X> fixedSet = FixedSet.noneOf(universe);
fixedSet.add("a");
// Throws "element not in universe" exception
fixedSet.contains("z");To test the performance, I created a universe of 150 enumerated values, then a set containing 100 values. Then I ran "contains" 30M times for 100 elements, 50 of which were in the set. Results:
TreeSet: 25 seconds
EnumSet: 2 seconds
FixedSet: 10 seconds
Profiling the code, the performance loss seems to be in a HashMap I use to map the Object to its index into the array of all elements. e.g.:
public abstract class FixedSet<E> extends AbstractSet<E>
  implements Cloneable, java.io.Serializable
  // All of the values comprising E for this set.
  protected E[] universe;
  // For reverse lookup
  protected Hashtable<E,Integer> ordinal;I have to do this because E doesn't necessarily have an ordinal value (EnumSet uses Enum.ordinal()). Unfortunately the hash lookup is now a bottleneck.
This brings me to my next question: I was thinking of replacing the hashtable by creating an inner class that extends E and adds an ordinal value that I initialize during creation of the FixedSet. e.g.:
public abstract class FixedSet<E> extends AbstractSet<E>
  implements Cloneable, java.io.Serializable
  // All of the values comprising E for this set.
  protected EOrdinal[] universe;
  protected class EOrdinal extends E {
    int ordinal;
    int ordinal() { return ordinal; }
  }The compiler doesn't like this. Can anyone suggest a solution?

Similar Messages

  • I am looking for a real time CRM consultant who can teach me in Bangalore ?

    I am looking for a real time CRM consultant who can teach me in Bangalore ?
    Call me on 7204246238

    If you are looking for a Creative player only The Zen V and Zen V plus are good options. I think they will satisfy most of your requirements.
    Strike that, I don't think this will act as an "external hard dri've" as described in bMessage Edited by fdreinthea on 2-2-200605:37 AM

  • Looking for a real photo editing app.

    I'm looking for something that can precisely resize and crop. None of this slider bullcrap where you can't get pixel level precision. I'd like to be able to crop at exactly 640x960 for example, or resize to exactly 820x620, etc.. Something that can do non destructive edits and that can save a jpeg without compressing it so much that image quality is noticably less. Photogene2 is great (nice edit features and good quality saves) but it can't crop or resize exactly by the pixel. Phototoaster is great (nice edit features and non destructive edits) except it can't crop and resize by the pixel. How hard would it be to provide numerical inputs for crops and resizes? Is there anything out there really worth buying that can do these essential tasks?

    Photoshop Touch
    https://itunes.apple.com/sg/app/adobe-photoshop-touch/id495716481?mt=8&ls=1

  • Looking for a real mentor

    I am new to the programming world in general and I have been getting used to the programming mindset and reading like a med student while practicing in Xcode.
    I am looking for a local, experienced Mac developer with patience to instruct and also "look over my shoulder" while I code my first apps. Mainly I need someone to tell me "there is an easier or better way to do that" or "you idiot" or "read this chapter" or something along those lines. I am brand new to programming, but have a high aptitude for learning and retaining. I have many questions and need some one on one instruction since there are not really any classes that are cost effective nearby. Consider it propagating the species or something cool like that.
    In return, I know many projects that need experienced contract developers .
    I am in the Fort Lauderdale area.
    I also know of many people in the area that are interested in the same so maybe we can get a class together and you can charge them for the classes...Just a thought.
    Thanks in advance.

    Hi Murray,
    There were a couple of reply's. I could not make either one work. I tried contacting you several times. The answer you gave me does not work. It is probably piIot error.  would like to talk to you about it. Can I call you? If so, send me your telephone number and I will call.
    Thanks for the followup.
    Jim

  • Not trying to flame NI, looking for some real feedback

    I have been using LV since version 2.   Serious use started in version 4. 
    When version 7 came out, I needed another license and bought a copy but continued to use version 6.  I tried installing 7 but it was so different from the older versions I removed it.    Recently I had to upgrade to version 8.2.1.    I have been using it for a few months now.    While it does have a few features that I actually like, the problems that I see with it far out weighed the improvements. 
    I am talking about things like speed,  version 8 is a dog compared to 6.  Just simple things like connecting a wire is very slow now.  Other things like doing a simple drag operation where I draw a box around the objects I want to drag and the box that LV shows is some where in deep space.  It selects the right objects, but seening the box not where you draw it just makes it not very smooth to use.   Then there is the moving of some of the drop down menus for no good reason that I can see.  Some MBA or manager should have been fired over that one.  Even after 2 months I still hit the wrong menus.  Just from having used LV for so many years I have developed a habit.  You poor people that need to run both versions!!  Then there are the crashes.   I don't even want to think of how much time I spend trying to find functions now....
    Some of this I am sure can not be helped I'm sure but the bugs with the select box, graphic entry speed  and crashes are something I am not used to with LV.   Over time I will get used to the new menus as long as they don't move them again.  This version IMO was the worst I have seen from them.  We needed some of the low level features it has, so we are stuck. 
    My question is if I upgrade to version 8.5, has National just added more fluff that I will never use, or have they actually improved the graphical entry speed and made it a more bug free environment?    

    Thanks for all of your input.
    We have a six licenses for LV and use it on a few different types of PCs.  All run much slower now that we did the upgrade.  The PC I am currently using has an Intel P4 3GHz w/ 2GB of RAM.  It has an NVIDIA dual view something card with two LCD monitors.    When I upgraded to version 6, I was running on a PIII 750MHz with 512M and it worked fine.  For that matter, I own a copy and use it at home on an old dual 200 MHz Pentium and it runs fine (yep that right).  It's not just the startup that I think it slow (which it is) it's just the normal drawing that is a real drag for me.   Run time seems fine still for the most part.   However, I tried to put the new version 8.2.1 on my LeCroy 8500A DSO to do some post processing.  Just loading LabView with no pannel was enough to bring the DSO to it's knees.   I gave up on this idea real fast. 
    I am not sure what a big VI would be.  Typical program for me may have 20 sub VI's, some calls to external DLL's to talk to some hardware and a lot of math.  Looks like the current program I am working on is about 2 Meg in size total (all the VIs added up).  Not what I would call big.
    I like LabView.  It has saved me countless hours over the years and I have brought up many prototypes and done a lot of tests with it.  I just don't like this version.  I'm not really into all the cute little things they add.  I use it to get work done.  If they have forgotten that feature (that it needs to actually work) then they missed the point.  
    I may just order one license just to see if there is any improvements.   It sounds like you have uncovered problems that I have not yet ran into so it may be good just to have it in my bag of tricks.  
    Thanks again. 

  • Smartforms - delete old variables - looking for a real expert

    Hi folks,
    Is there any possibility in Smartforms, that I don't know, with which I can analyse my fom. I want to check which variables aren't needed any more. So that I can delete them and I have a nice and clean form.
    How I loved my analyse tool in sapscript... I would write an new one, but I didn't found out how the texts are saved in the system.
    Is there anybody out there, who can help me?
    Regards
    Silvio

    Hi!
    For an extended check you can do the following:
    - check out which FM belongs to your smartforms (smartforms transaction - environment - function module name)
    - go to SE37 - View - Check - Extended program check
    Regards
    Tamá

  • Looking for good real time STOCK program for my Mac (free)

    Hi there!
    I wanted to throw this question to you guys out there. Does anyone know of any good, may be free, program to keep track of stock quotes in real time. Something with a real time running line with quotes. It would be nice to have something just sitting as a background on my desktop or as a wedget or in the dock, something that can do real time though.
    Please advice.
    Thanks

    Yuri:
    Yahoo Finance will give you real time quotes on specific stocks, say, in a portfolio. Many brokerage firm websites like Ameritrade offer Real Time quotes, too, but require that you have an account. Some other sites, and I don't remember exactly, offer a ticker tape type display; off the top of my head I'd say Intuit, CNN Money, MSNBC. Or you can try Market Browser.
    If I think of anything else I will post back.
    cornelius

  • Looking for a good tutorial or book for 3D composite

    Hi, I do editing for 3D animation at work (simple kind) and working along with 2 other 3D modelers.
    We recently came down to the conclusion that we need to composite to be able to render our animation.
    However, none of us really know how to do 3D composite, including myself.
    (I mean we know the simple composite using alpha channels and such... but not to the point to using z-depth or shadow maps... etc..).
    I was looking around online and book store to find out if there is any good resources for us to learn. I do not have much luck of it, unfortunately.
    I'd like to have our 3D modlers to know how to split to all different layers for a clean composite purpose.... (like for me to use in Shake ). From what I found out, higher end composite, you can split most of the gemoetries its own object IDs, and shadow map/layers, lighting layers... (even they render separetely, it do cast shadow as other objects surrounds it, or refection..) and then composite in one scene.
    I believe we create pretty good animation when we rendered them all together in one scene, and now we are up to the point that there are too many geometeries and render farm computers can't handle to render (and they are not lower end compters but they crash when we try to render with not enough memories).
    I'm not really looking for having real footage as background and 3D infront .. that kind of composite...
    If there is anyone can direct me to a right book? or online website to learn more of this stuff for all of us, I'll be really appriciate it.
    Thank you for your time...

    These might get you started as well:
    http://www.computerarts.co.uk/tutorials/3d_and__animation/boulderdash
    http://www.3drender.com/light/compositing/index.html
    http://www.3drender.com/jbirn/ea/Ant.html
    http://www.ethereal3d.com/Tutorials/Compositing/Compositing.html

  • Looking for a leather case for the ipod Touch 4G

    Hello everyone,
    I'm looking for a real *GENUINE LEATHER* case for the iPod Touch 4G, preferably one that has a belt clip.
    I just wasted $34 on the new Belkin "genuine leather case with belt clip" only to find out it smelled like rubber and felt nothing like what real leather would feel/smell like. Totally disappointed in Belkin advertising their cases as genuine leather when in fact they are made of cheap synthetic leather.

    You can right click your video file, go to "Get Info", and select the Video tab and change the file type to Movie, TV Show, or Music Video, and then once that video is synced to the iPod it will be sorted into the proper location.
    You can also create playlists of your video content. That would be the easiest/best way to get your genre classification system going.

  • Looking for a DVR, any suggestion?

    i'm looking for a real good DVR, similar to TIVO, that doesn't require a monthly subscription.

    Paying a subscription is often up to your service provider... such as cable or satellite
    Try http://www.avsforum.com/f/100/digital-recorders-pvrs-general

  • Looking for Bass plugin like Musiclabs 'Real-Strat'

    Basically I'm looking for a very realistic Bass guitar AU that works similarly to Realstrat. It needs to cater for natural slides and ideally have performance repetitions. I've tried using the EXS patches to no success and I can't find anything on the market. There's loads of these things cropping up now (EZ Drummer etc) but I don't see a bass version...
    Does anyone have any recommendations? Thanks in advance.

    Yes - wait for Spectrasonics' Trillian which should be here in a month or two.
    Or, Scarbee do some excellent bass libraries for Kontakt (if you have that) - Black Bass etc which have performance articulations and intelligent on-the-fly automatic articulation switching.

  • Looking for a simple, standalone desktop app for web stats

    Well, I see they've changed the forums here again. SIGH.
    Anyway, a certain web host has eliminated AWStats from it's shared hosting. So I used Webmaster Tools. And now they've changed, and no longer display the simple visitors and hits. Google Analytics is way too complex for what I need, as are many of the stats programs I've looked into.
    I can download the daily Apache log files, that's no problem. Just looking for a small standalone program to import these and show the data like AWStats.  Any suggestions? The only other options would be to go to a different web host. Not a big deal overall, but I would rather not deal with the hassle, especially the migrating the database.

    Not sure of standalone 'desktop' apps. But check out http://www.openwebanalytics.com/ and Web Analytics in Real Time | Clicky  - they're both very intuitive and easy to use with a lot more simplified stats than Google Analytics.

  • I'm looking for an app to help with math tutoring.

    I doubt that I will find exactly what I am looking for, but if anyone can provide suggestions, I would appreciate it. Groupboard is close, but has a few fatal flaws.
    Criteria List(required):
    Whiteboard where I can see what my student is writing in real time.
    Either latex support or the ability to quickly post one image at a time, at least 10 (20 is better) images per session.
    Only I have the ability to erase things or clear the board, not the student.
    Criteria List(would be helpful):
    Shape drawing tools
    Coordinate grid
    Formula editor (my students have no desire to learn latex)
    It would be best if I can post PDF's but jpegs will work just as well. What I would really like would be www.scribblar.com on an iPad. Unfortunately, it will not run on iPads.
    Any suggestions are greatly appreciated.
    Thanks.

    You might look at the iPads in Education site...
    http://ipadeducators.ning.com/

  • New Mac user looking for help with Finder, Preview, Keyboard, & Dock

    So about a month ago I switched over from a lifelong Windows user to a brand new MacBook Pro, and while I am adjusting pretty well, there are still some things that I haven't quite figured out.
    First up on the list is Finder! I like my files to be arranged just like how they are in Windows Explorer--folders first alphabetically, then files alphabetically. I've managed to acquire this setting by messing around with the "clean up by" and "arrange by" functions but I don't really know the specific combination. Most of the time these preferences are saved and set as the defaults under "View Options" but every once in a while it resets and I have to tinker around with the settings all over again. Does anyone know of a way to fix this? It's only happened twice so far, but I'd rather not have it happen again. Also, occasionally when I delete an item, there is a blank space left where the icon was instead of all the files following it bumping up a space. Any quick fixes for this bug?
    Next up is Preview. Again, I like the Windows Way and I like to be able to browse between the files in a folder while using Preview/Windows Photo Viewer. I know that there is a way to browse between files if you select the whole folder and stick it in Preview, but is there a way to achieve the same result without having to do that? An app or "extension" of some sort that adds arrows in to browse between photos? I've had no luck finding anything other than the aforementioned option. Is there a good free alternative to Preview that will function similarly with the browse between photos option?
    One of my favorite things about my new Mac is the backlit keyboard function. My old laptop didn't have it and as someone who is online more often at night it is super helpful. But is there a way to turn it off during the day/in bright settings? A way to put it on a timer? In System Preferences I selected the option "Adjust keyboard brightness in low light", which I assumed to mean would have the keyboard NOT very bright when there IS light, but it continues to light up just the same. Any apps or extensions to help with this one?
    And finally, the dock! This question is more about aesthetics than functionality but help is appreciated all the same. Currently, my dock looks like this: http://i42.tinypic.com/35ktxlz.png It is rather opaque and the indicator lights can barely be seen. However, in a lot of tutorial videos I've been watching, many people have docks that look like this: http://i.i.cbsi.com/cnwk.1d/i/tim/2011/07/19/Lion_LaunchPad.png It is a darker shade of gray, the divider is dashed rather than a straight line, and the indicator lights are clearly visible. Does anybody know how to get this look for the dock? I've looked in the dock preferences but there's not really anything in there other than magnification/size/effects.
    That about sums things up! I'm sorry if any of these seem like "silly" questions but they are all things I have been unable to find answers for. Any and all tips, tricks, and help is appreciated! Thanks in advance for all your help!!

    congratulations on coming over from the dark side.
    Seems like you are interested in column view, which would show you the hierarchy of folders and files:  Column View in Mac OS X Mountain Lion - For Dummies Not sure what's going on if your finder settings don't stay put. May be a corrupted preferences file, which is easy to fix, but is perhaps a topic for another discussion.
    What I'd suggest is to have an open mind and try to see what the mac can do, rather than force it to look like your windows machine. I mean, if you just want it to look like windows, then why bother switching? If you give it a little time, you'll start to appreciate the mac way of doing things, and see how it is infinitely more awesome, powerful, creative, intuitive, and better designed (and the software way better written)  than what you left behind. But that's your call.
    There are some threads on this forum with complaints about the backlight. Keyboard backlight settings query...: Apple Support Communities  Evidently it depends on the angle of the screen and the light sensor relative to the light. Some suggest that a SMC reset may help: Intel-based Macs: Resetting the System Management Controller (SMC)  This is not an issue for me, I just adjust the brightness with the keyboard buttons if I want. Real men shift their own gears, drink their coffee black, and adjust their own keyboard brightness. I am not aware of any software to exert more control over this feature but a search of macupdate  Download Apple Mac Software & iPhone Software : MacUpdate may help. I mean, it's up to you what is important. I can waste a lot of time playing around with the GUI and with unnecessary software, or I can just get my work (and play) done.
    You might prefer the no-glass dock, that removes the shelf, and makes the indicator lights like more discrete orbs. You can do this with the terminal. Using the terminal is also, perhaps, a topic for another discussion.I like the 2D dock much better. If you want I'll give you some directions for how to do it. Otherwise, here's a reference: 2D Dock - MacRumors Forums

  • I'm looking for a new small, efficient media player.

    Hi there.
    The background that will give you insight into my situation but doesn't need to be read
    I come from a very cushioned past media-wise. When I really started to get into listening to music I was still using Windows. It was Winamp first, which I liked but found a little much, but a few coincidences later found XMPlay, a free but closed-source media player capable of playing not only some weird file formats such as MO3, MOD, IT, XM, S3M etc, of which I have a few files in this format, but also MP3, OGG, WAV, and all the other general stuff out there. The timing was just perfect and I "grew" into my "media years" with this player. I used it across my transition from Win98 to XP, and also used it on a Win95 laptop - and I don't even think I had to "help" the system "like" the player to make it work, although I could be wrong.
    However, XMPlay has no Linux version, and as far as I can see, no porting is planned. And as I said before, it's closed source, so not much can be done there.
    In my setup I had a machine set aside for media playback because it had a SB16 in it, and I'd run it with the bass set to 100% and treble set to 0%. Despite what you might think, the output was awesome with headphones - it could give me a good headache or two without distorting at all.
    So, when I first switched to Linux, I didn't initially switch this machine over, but left it running Win98. This got to me in the end so I switched it over... and immediately faced issues. Since there was no port of XMPlay, I needed to find a new player, and fast. XMPlay has a bunch of audio postprocessing features I had enabled, none of which I found support or equivalents for in Linux (for example, an EQ setting promoting bassboost, in addition to that provided by the card - you can understand the headaches). I eventually gave up and ran XMPlay using WINE... and left it that way, for several months. I mean, it worked, didn't it? Then the fact that XMPlay over WINE on a 450MHz processor (it's a P3, haha) used 50%+ CPU -minimum- for the player to even be running (IIRC) got to me, so I decided once again that a new player had to be found. After some digging, I found XMMS to be the most likely candidate (it supports LADSPA and I could configure a bass-boost filter), and for the most part, it worked well. Quite well.
    Then... after I recently found myself recording some audio from the SB16's output to my main machine's input (the simplest way to get around the issue that the bass boost isn't very easy to feed back into the card - or impossible, I haven't tried it for so long), and had my headphones connected to my desktop to monitor the recording. Then, after that was done, I somehow started listening to some other piece of music (through my main box), for whatever reason. I immediately noticed a rather stark contrast in quality to what I'd recorded from the SB16 and what I was listening to. A doublecheck later confirmed that yes, my SB16 was of terrible quality, and yes, I needed a solution, since I wasn't gonna listen to that kinda sound quality anymore now that I knew.
    Over the past few weeks (months?) up until this point I've slowly been weaning myself off the music I liked so much (XMs and MODs, and maybe the occasional S3M), and the postprocessing features I thought had glued themselves into my ears....
    The, uh, like, point.
    ....so I need a media player that doesn't have much in terms of sound processing, but meets all the following requirements, either built in or as a plugin (as logically applicable):
    * Can hide completely, leaving only a hotkey to bring it back. I don't use a system tray and don't want to, for any purpose.
    * Is written in a compiled language.
    * Has configurable global hotkey support
    * Isn't bloated, dependancy-wise, filesize or memory-wise, or desktop-real-estate-wise - something that uses basic C and has a basic GUI preferred
    * Controls the hardware volume so that volume changes are instant
    * Supports tracks longer than 60 minutes / 1 hour
    * Has good file management / playlist support
    * Is something I can throw a gigantic directory tree at and expect to load all the music in it, FAST. I could throw my entire 32GB HDD at XMPlay when I wanted to see/remember what new music was on it and I'd just leave it alone for slightly under 5 minutes. When I returned to it, bam, playlist. That was on the 450MHz P3, running Win98. XMPlay also gave me feedback - if you can recommend something that shows me where it is on the filesystem, that'd be great.
    Up until now, Audacious has met those requirements. But it's had the following issues:
    * The track details window won't open for random tracks
    * The time display stuffs up for tracks longer than >60m, showing the position at 0:59, then, 1:40, then after 10 minutes have passed 1:41, etc
    * The volume control randomly forgets how to change the volume, and I refuse to change the controller to use a software volume since it'll induce delays
    * The system has no ability to add directories recursively - this was present in XMMS, but the BMP guys removed it (?!?!?!) and since Audacious is a fork of BMP, ...
    * The latest version's global hotkeys plugin restores the window to a non-changeable location when I use the "toggle player windows" function. As a visual person I find this a huge blocker.
    Now for the list of players that don't do what I want. XD
    * mpd - expects all your files to be in one folder; mine are everywhere, even thrown across sshfs mounts to other systems.
    * audacious - ...
    * xmms - too boring. GTK1. old stuff. unsupported.
    * xmms2 - seems too "unreachable". I haven't tried this player yet, mostly because Arch has no clients in the repos. *stab*
    * banshee - 200TB of dependencies, and it needs 400TB of RAM to run. Read: I dislike Mono.
    * rhythmbox, banshee, amarok, exaile, quod libet - iTunes-ey UI. I hate iTunes-ey UIs.
    * songbird - depends on the Gecko rendering engine. I have 512MB RAM, and I already run Firefox, thanks.
    * bmp, xmms, audacious - winamp-ey UI. I want to move away from winamp-ey UIs.
    If you have any suggestions... I'll be amazed.
    -dav7
    Last edited by dav7 (2008-09-09 12:55:22)

    * Can hide completely, leaving only a hotkey to bring it back. I don't use a system tray and don't want to, for any purpose.
    Sonata, disable system tray icon, modify any panel settings to ignore it
    * Is written in a compiled language.
    mpd is written in C
    * Has configurable global hotkey support
    Set up keybindings for mpc commands
    * Isn't bloated, dependancy-wise, filesize or memory-wise, or desktop-real-estate-wise - something that uses basic C and has a basic GUI preferred
    mpd uses basic C, many, many GUIs for it around, extremely small memory footprint
    * Controls the hardware volume so that volume changes are instant
    Keybind alsamixer commands
    * Supports tracks longer than 60 minutes / 1 hour
    Is there a modern media player that doesn't do this?
    * Has good file management / playlist support
    I never use mpd's playlist capabilities, but they do seem fairly extensive.
    * mpd - expects all your files to be in one folder; mine are everywhere, evn thrown across sshfs mounts to other systems.
    Apparently you have never heard of symbolic links. OH SNAP! Just create a single directory to collect all the links in. Also, mpd does not expect everything to be in one folder; it expects everything to be available from one parent folder, allowing you to organize beneath that parent.
    The problem you're having isn't that you're looking for a music player, you're looking for a wm/media player/file manager, and that just doesn't exist on Linux, largely because we are sane (for the sake of argument, ignore Songbird right now, I don't think any of us are crazy enough to use it anyways). Like looking for a zebroctonoceros, even though a zebra exists, an octopus exists, and a rhinoceros exists, they do not exist in the same creature. For interfacing with X (keybindings and the disappearing music player), you're better off going through a configurable wm like Openbox. For the actual music playing, well, I don't see any problems with mpd besides your music files being messy, and you can't expect music playing software to solve a personal organization problem. If your file system is messy, then use a file manager to fix it, not your mp3 player. I put a lot of effort into keeping my music files properly tagged and accessible from a single top level directory called music, which then splits off into mp3/ogg files, flac files, podcasts, etc, and that largely solves the problem of wondering where s--t is.
    Another idea for you, if you have multiple machines. Collect all your music onto a single machine, and then set up that system to serve exclusively as an mpd jukebox you can listen to from your other computers over the network. Give it a try.
    Last edited by coarseSand (2008-09-11 16:03:31)

Maybe you are looking for