swap

How to swap two image views using drag and drop in Android?

喜你入骨 提交于 2019-12-23 08:33:12
问题 I've been trying to implement a very simple drag and drop in Android, where the dragged item swaps positions with the item it was dropped on. I've successfully implemented the onLongClick and onDrag listeners. When I drag and drop an item it replaces the item it was dropped on, but I can't figure out how make the replaced item take the place of the dragged item. I spent a while searching for answers, but most answers just linked complex implementations of drag and drop involving many files

How to swap a number of the values between 2 rows in R

筅森魡賤 提交于 2019-12-23 04:51:43
问题 I have a matrix with the size of 10x100. How can I swap the values between row 1 and row 2 in the first 30% of the columns? 回答1: We can just reverse the row index for the 1st two rows along along with column index created by taking the sequence of round ed 30% total number of columns for swapping the values in the rows. colS <- seq(round(ncol(m1)*0.3)) m1[2:1, colS] <- m1[1:2, colS] data m1 <- matrix(1:1000, 10, 100) 来源: https://stackoverflow.com/questions/38805833/how-to-swap-a-number-of-the

Staying away from virtual memory in Windows\C++

家住魔仙堡 提交于 2019-12-23 03:09:43
问题 I'm writing a performance critical application where its essential to store as much data as possible in the physical memory before dumping to disc. I can use ::GlobalMemoryStatusEx(...) and ::GetProcessMemoryInfo(...) to find out what percentage of physical memory is reserved\free and how much memory my current process handles. Using this data I can make sure to dump when ~90% of the physical memory is in use or ~90 of the maximum of 2GB per application limit is hit. However, I would like a

Image Replacement (gallery style) with Fade-In's / Fade-Out's

a 夏天 提交于 2019-12-22 10:16:32
问题 I'm sure you've all seen this demo of image replacement using this : $("#largeImg").attr({ src: largePath, alt: largeAlt }); http://www.webdesignerwall.com/demo/jquery/img-replacement.html So, imagine that I want to change 4 images on the screen to simulate that I am changing the entire 'page' , but avoiding using AJAX / PHP or any image preloaders. The problem I am having right now with my code : <script> $(document).ready(function(){ $(".navlink").click(function(){ var theirname = $(this)

How do you know what you've displayed is completely drawn on screen?

左心房为你撑大大i 提交于 2019-12-22 09:56:19
问题 Displaying images on a computer monitor involves the usage of a graphic API, which dispatches a series of asynchronous calls... and at some given time, put the wanted stuff on the computer screen. But, what if you are interested in knowing the exact CPU time at the point where the required image is fully drawn (and visible to the user)? I really need to grab a CPU timestamp when everything is displayed to relate this point in time to other measurements I take. Without taking account of the

string swapping works well with char ** but not with char *

守給你的承諾、 提交于 2019-12-22 09:38:20
问题 In this program I have swapped the first 2 names #include<stdio.h> void swap(char **,char **); main() { char *name[4]={"amol", "robin", "shanu" }; swap(&name[0],&name[2]); printf("%s %s",name[0],name[2]); } void swap(char **x,char **y) { char *temp; temp=*x; *x=*y; *y=temp; } This programs runs perfectly but when I use the function swap(char *,char *) it does not swap the address why? why I have to use pointer to pointer? 回答1: I assume you understand that to swap integers you would have

Why are the swap member functions in STL containers not declared noexcept?

♀尐吖头ヾ 提交于 2019-12-22 02:04:50
问题 As of N3797 the C++ standard requires swap functions of containers to not throw any exceptions unless specified otherwise [container.requirements.general] ( 23.2.1§10 ). Why are the swap member functions that are specified to not throw not declared noexcept ? The same question applies to the specialized non-member swap overloads. 回答1: Further to what refp said, here's a post from Daniel Krügler on the std-discussion mailing list: The internal policy to declare a function as unconditional

Can the xor-swap be extended to more than two variables?

好久不见. 提交于 2019-12-21 17:23:11
问题 I've been trying to extend the xor-swap to more than two variables, say n variables. But I've gotten nowhere that's better than 3*(n-1) . For two integer variables x1 and x2 you can swap them like this: swap(x1,x2) { x1 = x1 ^ x2; x2 = x1 ^ x2; x1 = x1 ^ x2; } So, assume you have x1 ... xn with values v1 ... vn . Clearly you can "rotate" the values by successively applying swap: swap(x1,x2); swap(x2,x3); swap(x3,x4); ... swap(xm,xn); // with m = n-1 You will end up with x1 = v2 , x2 = v3 , ..

Why does `basic_ios::swap` only do a partial swap?

≯℡__Kan透↙ 提交于 2019-12-21 07:15:12
问题 C++11 §27.5.4.2/21: void swap(basic_ios& rhs); Effects: The states of *this and rhs shall be exchanged, except that rdbuf() shall return the same value as it returned before the function call, and rhs.rdbuf() shall return the same value as it returned before the function call. What is this partial swapping useful for? Can it cause trouble? 回答1: You can blame me for this one. The committee has tried to change (twice I think), but each time the solution ended up breaking things. Swap and move

How to swap the bitmap images on View in android?

安稳与你 提交于 2019-12-21 06:28:15
问题 I am working with small application for display bubbles images on android screen.I have displayed all bubbles images from resource directory.I have implemented code as follows in view class. onDraw method: @Override protected void onDraw(Canvas canvas) { super.dispatchDraw(canvas); drawImages(canvas); } I have implemented drawImages() method as follows: BitmapFactory.Options opts = new BitmapFactory.Options(); private void drawImages(Canvas canvas) { for(int i = 0; i<MAX_ROWS; i++){ for(int j