efficiency

The best way to do :not in jQuery?

Hi, I have a menu in jQuery when you click on a link it opens up, but I want it so when you click somewhere else, anywhere else that is not the menu, it becomes hidden. At the moment I'm binding a click event to $(':not(#the_menu)') But this seems like I'm binding a click event to the entire minus the menu, is there a more efficie...

MySQL slow query

SELECT items.item_id, items.category_id, items.title, items.description, items.quality, items.type, items.status, items.price, items.posted, items.modified, zip_code.state_prefix, zip_code.city, books.isbn13, books.isbn10, books.authors, books.publisher FROM ( ( items LEFT JOIN bookitems ON items.item_id = bookitems.ite...

C++: Efficiently adding integers to strings

I know how to add integers to strings, but I'm not sure I'm doing it in an efficient matters. I have a class where I often have to return a string plus an integer (a different integer each time), in Java I would do something like public class MyClass { final static String S = "MYSTRING"; private int id = 0; public String getStrin...

django sitemap efficiency

I saw on this page that it's possible to lower the limit on your sitemap so that it is paginated differently: http://stackoverflow.com/questions/2079786/caching-sitemaps-in-django But when I try to generate my sitemap, it hangs and hangs, and never comes up. Eventually, if I wait long enough, I get this error in Firefox: XML Parsing E...

C++ - Efficient container for large amounts of searchable data?

Hello, everybody! I am implementing a text-based version of Scrabble for a College project. My dictionary is quite large, weighing in at around 400.000 words (std::string). Searching for a valid word will suck, big time, in terms of efficiency if I go for a vector<string> ( O(n) ). Are there any good alternatives? Keep in mind, I'm en...

How are databases efficient?

If databases can support up to millions of records, how is all of this data organized such that queries can be executed in a reasonable amount of time? ...

Two strange efficiency problems in Mathematica

FIRST PROBLEM I have timed how long it takes to compute the following statements (where V[x] is a time-intensive function call): Alice = Table[V[i],{i,1,300},{1000}]; Bob = Table[Table[V[i],{i,1,300}],{1000}]^tr; Chris_pre = Table[V[i],{i,1,300}]; Chris = Table[Chris_pre,{1000}]^tr; Alice, Bob, and Chris are identical m...

How do I efficiently write a "toggle database value" function in AJAX?

Say I have a website which shows the user ten images and asks them to categorise each image by clicking on buttons. A button for "funny", a button for "scary", a button for "pretty" and so on. These buttons aren't exclusive. A picture can be both funny and scary. The user clicks the "funny" button. An AJAX request is sent off to the dat...

Generics and Performance question.

Hey Everyone, I was wondering if anyone could look over a class I wrote, I am receiving generic warnings in Eclipse and I am just wondering if it could be cleaned up at all. All of the warnings I received are surrounded in ** in my code below. The class takes a list of strings in the form of (hh:mm AM/PM) and converts them into HourMi...

String Parsing in C#

What is the most efficient way to parse a C# string in the form of "(params (abc 1.3)(sdc 2.0)(www 3.05)....)" into a struct in the form struct Params { double abc,sdc,www....; } Thanks EDIT The structure always have the same parameters (same names,only doubles, known at compile time).. but the order is not granted.. only one s...

FacesMessages and rich:effect?

I'd like to be able to make an Ajax call using JSF/Seam/RichFaces and have the page update with the relevant h:messages component. That works with no problem. I'm able to perform the appropriate reRender. However, I'd also like to be able to make use of rich:effect to make it a bit prettier. Ideally, I'd like to be able to have the m...

Design Question: communication between objects within same client-server app

Have a SocketClient which communicates asynchronously with a server. SocketClient relies on Socket.BeginReceive() and Socket.EndReceive() to communicate. As incoming data is received by the Socket, it's immediately decoded by System.Text.Encoding.UTF8.GetDecoder() and parsed into strings delimited by '\n' char, which strings are then pas...

Is there any way to make this JavaScript tab completion script more efficient?

This code is to be integrated into an AJAX Chat system to enable a tab auto-completion of user names: var usernames = new Array(); usernames[0] = "Saladin"; usernames[1] = "Jyllaby"; usernames[2] = "CadaverKindler"; usernames[3] = "qbsuperstar03"; var text = "Text and something else q"; // Start of the script to be imported var search...

Efficiently adding or removing elements to a vector or list in R?

I'm implementing an algorithm that involves lots of adding and removing things from sets. In R, this is slow because as far as I know, adding or removing things from a vector is slow, since the entire vector has to be re-allocated. Is there a way do do it more efficiently? Edit: My current solution is to use a boolean vector of the same...

How can I make my javascript chat polling script be more efficient?

For some reason this check for new chat messages causes a larger amount of browser (and to some extent server) load than I would expect. Anyone see any ways that I can make it more efficient, to lessen the load? // Begin the cycle of refreshing the mini chat after the standard delay. function startRefreshingMinichat(){ var secs = 3...

What is the best file format to parse?

Scenario: I'm working on a rails app that will take data entry in the form of uploaded text-based files. I need to parse these files before importing the data. I can choose the file type uploaded to the app; the software (Microsoft Access) used by those uploading has several export options regarding file type. While it may be insignific...

Efficiency of Java code with primitive types

Hello! I want to ask which piece of code is more efficient in Java? Code 1: void f() { for(int i = 0 ; i < 99999;i++) { for(int j = 0 ; j < 99999;j++) { //Some operations } } } Code 2: void f() { int i,j; for(i = 0 ; i < 99999;i++) { for(j = 0 ; j < 99999;j++) { //Some operations } } } My teacher said tha...

Is scala functional programming slower than traditional coding?

In one of my first attempts to create functional code, I ran into a performance issue. I started with a common task - multiply the elements of two arrays and sum up the results: var first:Array[Float] ... var second:Array[Float] ... var sum=0f; for(ix<-0 until first.length) sum += first(ix) * second(ix); Here is how I reformed t...

Scala: What is the right way to build HashMap variant without linked lists ?

How mouch Scala standard library can be reused to create variant of HashMap that does not handle collisions at all? In HashMap implementation in Scala I can see that traits HashEntry, DefaultEntry and LinkedEntry are related, but I'm not sure whether I have any control over them. ...

Most efficient approach for multilingual PHP website

I am working on a large multilingual website and I am considering different approaches for making it multilingual. The possible alternatives I can think of are: The Gettext functions with generation of .po files One MySQL table with the translations and a unique string ID for each text PHP-files with arrays containing the different tra...