efficiency

Comma seperated textbox value to list/array of strings - Is there a better way to write this code?

I want to create an array/list of strings of the Comma seperated strings (file extensions) that are entered in a Textbox. For the following block of code: Dim csv As String = Textbox1.Text + "," While csv.IndexOf(".") <> -1 lstOfStrings.Add(csv.Substring(0, csv.IndexOf(","))) csv...

How to efficiently implement an event loop?

COM Object (Server) sends event notification successfully to COM Client Without: ATL MFC How to efficiently get the main thread to wait/sleep (infinitely) until COM Server notifies the COM Client of a particular event? ...

JavaScript: Is IP In One Of These Subnets?

So I have ~12600 subnets: eg. 123.123.208.0/20 and an IP. I can use a SQLite Database or an array or whatever There was a similar question asked about a month ago, however I am not looking for checking one IP against one subnet but a bunch of subnets (obviously the most efficient way, hopefully not O(total subnets)) :) How can I ch...

Efficiently wait for a flag state change without blocking resources?

Thread to wait infinitely in a loop until a flag state change, then call function. pseudo code illustration: while (true) { while (!flag) { sleep(1); } clean_upfunction(); } Currently: Using the multithreaded versions of the C run-time libraries only No: MFC Question: Is there a more efficient way o...

How do I know my XSL is efficient and beautiful?

As a programmer, I am developing programs in procedural and OOP languages for many years now, and I guess I know beautiful and efficient code when I see it (or when I write it). Recently I started to work with XSLs, and while they deliver the results I expect, I have no idea whether they are nice and beautiful and efficient. (well, they...

Project Euler #5 php doubt!!!

problem euler #5 i found the solution but i don't know why this first code is faster (i put 14 in order to try to make more clear the code) the only difference is that i eliminate the for i wrote for a huge if if($num%14==0 && $num%13==0 &&$num%12==0 &&$num%11==0 &&$num%10==0 && $num%9==0 && $num%8==0 && $num%7==0 && $num%6==0 && $num%...

Web-Developer's Project Template Directory

IMPORTANT: The accepted answer was accepted post-bounty, not necessarily because I felt it was the best answer. I find myself doing things over and over when starting new projects. I create a folder, with sub-folders and then copy over some standard items like a css reset file, famfamfam icons, jquery, etc. This got me thinking what ...

2-D (concurrent) HashMap: 2-property key type? hashmap of hashmaps? [update]

So I need a 2-dimensional ConcurrentHashMap. It has to be as blazing fast as possible, as I'm going to be adding to and updating its values extremely frequently. It's in a multithreaded application, hence the choice to use ConcurrentHashMap instead of just HashMap. Both the "x" and "y" indices are integers with a known range (0 throug...

Python: List vs Dict for look up table

I have about 10million values that I need to put in some type of look up table, so I was wondering which would be more efficient a list or dict? I know you can do something like this for both: if something in dict_of_stuff: pass and if something in list_of_stuff: pass My thought is the dict will be faster and more efficien...

How expensive is Java Locking?

In general, how expensive is locking in Java? Specifically in my case: I have a multi-threaded app in which there is one main loop that takes objects off a DelayQueue and processes them (using poll()). At some point a different thread will have to remove errant elements from the queue (using remove()). Given that the remove() is relat...

Minify an Entire Directory While Keeping Element/Style/Script Relationships?

Do any solutions currnetly exist that can minify an entire project directory? More importantly, do any solutions exist that can shorten classnames, id's, and keep them consistent throughout all documents? Something that can turn this: Index.html --- <div class="fooBar"> <!-- Code --> </div> Styles.css --- .fooBar { // Comments...

Is there efficient SQL to query a portion of a large table

The typical way of selecting data is: select * from my_table But what if the table contains 10 million records and you only want records 300,010 to 300,020 Is there a way to create a SQL statement on Microsoft SQL that only gets 10 records at once? Eg select * from my_table from records 300,010 to 300,020 This would be way more ef...

Dynamic data in postgresql

Hi world, I intend to have a python script do many UPDATEs per second on 2,433,000 rows. I am currently trying to keep the dynamic column in python as a value in a python dict. Yet to keep my python dict synchronized with changes in the other columns is becoming more and more difficult or nonviable. I know I could put the autovacuum on...

JAVA- Function to determine whether a poker hand is a straight?

Hello, for a homework assignment I was given a Card class that has enumerated types for the Rank and Suit. I am required to compare two pokerhands (each hand is an ArrayList of 5 cards) and decide the winner. The isStraight() function is really bothering me, because I have to start over the count after the Ace. For example, QUEEN, KING...

Efficiently iterate through all MATCHING keys in a hashmap?

I have a HashMap with millions of entries. Need to retrieve all entries whose keys match a specific set of criteria (in this case, each key is an object with two integer properties; I need to retrieve all keys where each of these integers fall within a specified range). What is the fastest, most efficient way to iterate through all suc...

Best Way to Constantly Update GUI Elements

Hi All I have a Java GUI that has a number of text fields, the values of which are populated from static variable in another class. I am interested to know what the best way is to make it so that when the variable is changed in another class, the update is instantly reflected on the GUI. If any one could make a suggestion on an effici...

Text replacement efficiency

An extension to my previous question: Text cleaning and replacement: delete \n from a text in Java I am cleaning this incoming text, which comes from a database with irregular text. That means, there' s no standard or rules. Some contain HTML characters like &reg, &trade, &lt, and others come in this form: &#8221, &#8211, etc. Other tim...

Efficient way of extracting specific numerical attributes from XML

The application I work uses XML for save/restore purposes. Here's an example snippet: <?xml version="1.0" standalone="yes"?> <itemSet> <item handle="2" attribute1="30" attribute2="blah"></item> <item handle="5" attribute1="27" attribute2="blahblah"></item> </itemSet> I want to be able to efficiently pre-process the XML which I read i...

Optimum search for k minimum values in unsorted list of integers

I was just interviewed with a question, and I'm curious what the answer ought to be. The problem was, essentially: Say you have an unsorted list of n integers. How do you find the k minimum values in this list? That is, if you have a list of [10, 11, 24, 12, 13] and are looking for the 2 minimum values, you'd get [10, 11]. I've got an ...

Mysql: Using LIKE vs. = for exact string match

First off, I recognize the differences between the two: - Like makes available the wildcards % and _ - significant trailing whitespace - colation issues All other things being equal, for an exact string match which is more efficient: SELECT field WHERE 'a' = 'a'; Or: SELECT field WHERE 'a' LIKE 'a'; Or: Is the difference so insign...