swap

Memory issues: Should I be writing to file/database if I'm using swap? (Python)

I'm creating and processing a very large data set, with about 34 million data points, and I'm currently storing them in python dictionaries in memory (about 22,500 dictionaries, with 15 dictionaries in each of 1588 class instances). While I'm able to manage this all in memory, I'm using up all of my RAM and most of my swap. I need to b...

Swap CSS style of a group of elements on click

I found a thread, http://stackoverflow.com/questions/195951/change-an-elements-css-class-with-javascript, that is along the lines of what I'm going for, but I don't know how to implement it. I have a page with 4 input buttons and two CSS styles: "Selected" and "notSelected". One button will be hard coded initially as "Selected". When ...

disable onmouseout function when onclick event is activated

My code looks like this using Image Swap of Dreamweaver. <a href = "#"> <img src="images/leistungen.png" alt="leistungen" name="leistungen" width="162" height="38" id="leistungen" onclick="MM_swapImage('home','','images/home_orig.png','philosophie','', 'images/philosophie.png','kontakt','','images/kontakt.png','body_layout','','images/...

how to get the image source in javascript?

I want to compare if the chosen image equal to the desired image.. Here's the initial code but is not working function mouseOut(txt){ var imgClick, imgOrig; imgClick = 'images/'+txt+'_onclick.png'; imgOrig ='images/'+txt+'.png'; if(document.getElementById(txt).src == imgClick){return false;} else {document.getElementById(txt).src = im...

Need help with logic (C)

I need to swap first n elements from two non repeating sequences(arrays), where n is a random integer. Seq1: 1 4 5 6 9 8 2 3 7 Seq2: 3 9 1 2 8 7 4 5 6 If n = 4 Seq1: 3 9 1 2 | 9 8 2 3 7 Seq2: 1 4 5 6 | 8 7 4 5 6 Now i need to repair the sequence by replacing the repeated numbers after '|'. How to do this? This is my effort.. for...

Passing temporaries as LValues

Hello I'd like to use the following idiom, that I think is non-standard. I have functions which return vectors taking advantage of Return Value Optimization: vector<T> some_func() { ... return vector<T>( /* something */ ); } Then, I would like to use vector<T>& some_reference; std::swap(some_reference, some_func()); but so...

C++ builtin to swap two numerical values?

Does C++ have a built in such as part of STL to swap two numerical values instead of doing: int tmp = var1; var1 = var2; var2 = tmp; Something like this: std::swapValues(var1, var2); Where swapValues is a template. ...

Limiting resident memory usage

I would like to limit the amount of physical memory a process can use without limiting the amount of virtual memory it can use. I am doing this in an effort to measure the behavior of various algorithms under memory pressure, and I need to test their performance with many different amounts of physical memory available - so I either need...

Best way to swap two records in TDataset Delphi?

New to delphi and database programming in general but am curious if there is a better way to swap records in a TDataset? I have read through some help and cant find any obvious methods. Currently I have a procedure implemented to move records down the dataset until they hit the Eof marker. However I am getting some odd errors when I get ...

Image Swap wont work in Firefox But works in IE

Hi, I'm a bit of a novice when it comes to coding but have been in the process of setting up my own webpage via Dreamweaver as the WYSIWYG approach waorks for me. The problem is I am trying to implement a disjointed image swap on click event.. It works fone for me on IE but not on firefox, and have been tearing my hair out trying to fi...

What's a good and functional way to swap collection elements in Scala?

Hi! In a project of mine one common use case keeps coming up. At some point I've got a sorted collection of some kind (List, Seq, etc... doesn't matter) and one element of this collection. What I want to do is to swap the given element with it's following element (if this element exists) or at some times with the preceding element. I'm...

std::swap returns 0xBAADF00D

Hi I'm trying to swap two std::list< dontcare* >::iterators under Visual 2005. Iter it1 = ... ,it2 = ...; // it1 and it2 are ok, not end() or such if(...){ std::swap(it1,it2); } The swap works, but when I leave the if() scope, it1 points to 0xbaadfood. It2 is ok though.I tried several variations, including swap_iter and a hand-ma...

Swap arrays by using pointers in C++

I have two arrays of pointers to doubles that I need to swap. Rather than just copy the data within the arrays, it would be more efficient just to swap the pointers to the arrays. I was always under the impression that array names were essentially just pointers, but the following code receives a compiler error: double left[] = {1,2,3}; ...

Sorting a two-dimensional toroidal array with rotations and swaps

I tried thinking of an algorithm, but couldn't do it. Here is the problem: There are 16 elements, grouped by four types (a, b, c and d). We also have four groups, A, B, C and D. In the initial state, the four groups have four random elements each, eg.: A: c, c, a, d B: b, b, a, a C: b, b, c, c D: d, d, d, a The order of elements in ...

python:[[1,2],[3,4],[5,6],[7,8]] transform into [[1],[2,3],[4,5],[6,7],[8]] and vice versa

my current solution-pointers would be ether via a iterator class which yields the new assembled inner lists or via a iter function which yields the new assembled inner lists is there another, better way to solve this challenge? Edit @Glenn: good objection. I wasn't thinking of that because I experienced lists not ordered in the ma...

find out what is the right block size for SWAP ?

i found the following method to create swap, from here dd if=/dev/zero of=/root/myswapfile bs=1M count=1024 Is there any thumb rule that to decide block size ? What is the best block size for Swap in any machine ? Here it is 1M.. ...

How to programtically monitor Windows swap space usage in real time?

I can write a program by using wmi to monitor the space usage of a hard drive. What should I do about swap memory usage? ...

how do you swap two rows in a matrix (in C)?

for example, given a matrix: 1 2 3 4 5 6 7 8 9 if you are goint to swap row[0] and row[1], resulting matrix would be: 4 5 6 1 2 3 7 8 9 can you guys help me get a code in C for this? ...

Right way to swap x elements in List

I started to learn Scala language and I have a question. How do you think, is it a right way to swap first and last x elements in List in a functional style? def swap(l: List[Any], x: Int) = { val l1 = l.take(x) val l2 = l.slice(x, l.length - x) val l3 = l.takeRight(x) l3 ::: l2 ::: l1 } It doesn't matter what happened if x wo...

Swapping Objects in an Array - C#

In C#, I have an Array of MenuItem. I'm trying to swap the two Objects in index 2 and index 3 of the array without success using the code below: MenuItem Temp = Items[2]; Items[2] = Items[3]; Items[3] = Temp; There must be a reason why the second and third lines aren't working in C# which I may not understand yet. Is anyone able...