Questions tagged [swap]

0

votes
0

answer
2

Views

How display chart axis in normal layout (Y-Vertical, X-horizontal)? (Auto-replace error with axis layout) [C# WindowsForms]

I try to print a point chart (WindowsForms) in normal layout (I mean axis X is horizontal, and axis Y is vertical), but when I do it, it auto changed axis location. After print I've got X in vertical and Y in horizontal. image -> https://ibb.co/7KvdfXr (I dont have 10 reputation rank...) How display...
Tom Mro
0

votes
2

answer
44

Views

swap and move infinite recursion

I have a very simple example class, compiled with C++17. #include #include struct name { std::string first, middle, last; name() = default; name(name const&) = default; name(name &&) = default; name& operator=(name o) { std::swap(*this, o); // bad! return *this; } }; int main() { name n1{'mr', 'jo...
meguli
0

votes
1

answer
19

Views

why the swapping does not take place when indices are 0 and 1?

I have an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. It is allowed to swap any two elements. I need to find the minimum number of swaps required to sort the array in ascending order. Starting from the first element of the list, I try to put them in...
Golluu
2

votes
2

answer
37

Views

python swaping values using comma is causing confusions

this involves a problem that I encountered when try to solve a linked-list reverse problem. First let me put some preliminary codes for the definition of the linked list and quick method to generate a linked list: class ListNode: def __init__(self, x): self.val = x self.next = None def __repr__(self...
0

votes
2

answer
28

Views

Difference between Atomic set() and getAndSet() methods in Java

In one of my programs, I was trying to update the value of an Atomic Integer, but could not decide between set() and getAndSet() methods because they both seem to do the same. //Sets the newValue to the volatile member value public final void set(int newValue) { value = newValue; } and public final...
Steve
1

votes
0

answer
379

Views

function to perform swapping in an array

The basic flow of the program is as follows: 1. Print the original content of array. 2. Ask the user for two indices X and Y. 3. Swap the two elements if Array[X] > Array[Y]. 4. Print the modified array only if swapping occurs. .data array: .word 8, 2, 1, 6, 9, 7, 3, 5, 0, 4 newl: .ascii...
greenland
1

votes
2

answer
47

Views

Swapping elements between more than 2 arrays

Swapping elements within a single array (x) is a classic problem in computer science. The immediate (but by no means only, e.g., XOR) solution in a low-level language like C is to use a temporary variable: x[0] = tmp x[0] = x[1] x[1] = tmp The above algorithm swaps the first and second elements of x...
compbiostats
1

votes
1

answer
284

Views

Replacing #pragma omp atomic with c++ atomics

I'm replacing some OpenMP code with standard C++11/C++14 atomics/thread support. Here is the OpenMP minimal code example: #include #include void omp_atomic_add(std::vector const& rows, std::vector const& cols, std::vector& values, std::size_t const row, std::size_t const col, double const value)...
fast asleep
1

votes
1

answer
64

Views

What is the correct way to swap elements in multidiamensional arrays in loops?

I have a piece of code that runs through a table and with a propability of 'pxover', swaps some elements in it. What elements should swap, are found with a propability of 0.5. The algorithm does the swap when two elements are found. The evaluation_table formation is this: [[(x11,y11),(x12,y12), ......
tzoukritzou
1

votes
1

answer
82

Views

Swap Nodes in Pairs

I am currently brushing up and reviewing my datastructures as I prepare for job interviews. I am currently working on this problem where I have to swap every 2 nodes in a Linked List. My code is as follows: public ListNode swapPairs(ListNode head) { ListNode dummy = new ListNode(0); dummy.next =...
Haki Dehari
1

votes
1

answer
203

Views

Swapping 1st and 2nd character of a string

I want to swap 2 character and 1st character. My code is: INCLUDE Irvine32.inc .data array byte 'scs212',0 .code main proc mov esi,array mov al,[esi] inc esi move bl,[esi] xchg al,bl dec esi move [esi],al inc esi move [esi],bl mov edx, offset array call WriteString exit main ENDP END main I'm t...
Hassan Butt
1

votes
2

answer
377

Views

Swap two neighborhood elements of array java

I am pretty new to java, usually writing python code, so you can downvote me as much as you want if only it will help me with understanding. Is there more less 'javish' way to swap two neighborhood elements of user-input array? Currently I have: public static void main(String[] args) { Scanner in =...
Java lava
1

votes
0

answer
44

Views

Need help. Redis works like a turtle with centos swap

Need help. Redis works like a turtle with centos 7 swap. I create swap in centos 7: sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile; sudo echo '/swapfile swap swap sw 0 0' >> /etc/fstab; Install Redis: yum -y install epel-r...
w3bc0d3r
1

votes
1

answer
84

Views

swap nodes in a linked list overflows java

/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ class Solution { public ListNode swapPairs(ListNode head) { if (head == null|| head.next == null) return head; ListNode curr = head;//current node in list...
Omar Elhosseni
1

votes
1

answer
638

Views

Excel VBA: How to swap two selected cell ranges (not only two values) within the same column?

I would like to swap selected cell ranges within the same column without having automatically adjusted attached formulas in other columns. Those cell ranges will almost always be of unequal size. I found a VBA code which does it for two selected cells, but im afraid that this wont help me much. Sub...
MarcoMarss
1

votes
0

answer
106

Views

Drag, drop and swapping elements between tables

Imagine i have this JsFiddle ç 10 20 30 40 50 60 function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData('src', ev.target.id); } function drop(ev) { ev.preventDefault(); var src = document.getElementById(ev.dataTransfer.getData('src')); var srcPare...
Tirant II
1

votes
0

answer
149

Views

python minimal modbus write float word swap

The PLC I am trying to use minimal modbus to write_float to needs the words swapped. I already tested the hardware with Modbus Poll that works. The Minimal Modbus write_float also works, but with the wrong word order. I checked the documentation solution for a read_float that works with workaround....
user3005949
1

votes
1

answer
59

Views

Regular expression ignore capturing group order

Please open following URL in chrome => https://regex101.com/r/rWLAOU/1/ Regex: \b(f|fall|w|winter|s|spring|su|summer)\b\s*(?
horse shoe
1

votes
0

answer
76

Views

Tensorflow: Reshape and swap elements from tensor(shape=[batchsize]) in a tensor(shape=[batchsize, 2]) with specific order

I have a tensor (shape=[batchsize]). I want to reshape the tensor in a specific order and into shape=[-1,2]. I want to have that specific order: Element at [0,0] Element at [1,1] Element at [0,1] Element at [1,0] Element at [2,0] Element at [3,1] Element at [2,1] Element at [3,0] and so on for an un...
yoboseyo
1

votes
0

answer
87

Views

Copy-swap idiom not recommended?

For a long time time I though that the correct way to implement a copy assignment (for a non trivial class) was to use the copy-swap idiom. struct A{ ... pointer to data A(A const& other){ ... complicated stuff, allocation, loops, etc } void swap(A& other){... cheap stuff ...} A& operator=(A const&...
alfC
1

votes
1

answer
66

Views

Copy&Swap efficiency for shared pointers

This can be seen as a follow up to e.g. Why shared pointer assignment does 'swap'?. The question is about the Copy&Swap idiom used e.g. in boost. I do understand that the benefit of Copy&Swap is to reuse existing code which avoids duplication and bugs. But there are 2 cases (actually 1 can be reduce...
Flamefire
1

votes
1

answer
308

Views

Get the list of azure web app settings to be swapped using PowerShell

When we perform the swap through the azure portal, it gives us the warning & informative messages regarding the settings to be swapped. Just like in below image: My question is, is there any way I can get these messages list (regarding the settings) through PowerShell code? I tried googling it but...
Naman Goyal
1

votes
0

answer
58

Views

Drag and drop swappable DIV JQuery UI

I've been wondering how to make swappable DIV with jQuery UI. I can't use list, I can use only table for my project. Now drag and drop work very well, but I'm not able to do the swap between DIV into the cells. I tried with sortable() function but nothing :( Thanks for your help. My CSS: table { wi...
Said Rwicha
1

votes
2

answer
228

Views

How to swap Character of string with the given condition?

def password(passlist): listt = [] for i in range(0, len(passlist)): temp = passlist[i] for j in range(0, len(temp)/2): if((j+2)%2 == 0) : t = temp[j] temp.replace(temp[j], temp[j+2]) temp.replace(temp[j+2], t) listt.append(temp) I am passing a list of string example ['abcd', 'bcad']. for each str...
Ashish
1

votes
0

answer
55

Views

How is swap handled on OpenVz 7?

I just recently started running an OpenVz7 environment with several production CT's and VM's. I am trying to understand how is swap handled on OpenVz7 CT's, because I ran into some issues (fixed a swap not being used issue; but still having higher than normal iops at random times). The main questio...
Ray
1

votes
1

answer
22

Views

Does swapping the value within the list exchange reference in Python3?

I am wondering if exchanging the values within the list items like below just exchange the value or the reference address. a = [1, 2] a[0], a[1] = a[1], a[0] print(a) # [2, 1] Under the hood of the mechanism of Python3, I am wondering which one from below is equivalent to the code above. Case1: Inse...
Backrub32
1

votes
1

answer
36

Views

Swap numbers from different lines (from fileinput library) without using temporary variables

I am aware that there are similar posts. But none of them seems to deal with input from the file input library. My biggest problem here is that I don't know how to handle each line generated from the for loop without assigning a temporary variable. I am doing a code practice question where the requi...
Bowen Liu
1

votes
0

answer
23

Views

Is there a common way to animate two items swapping position in an array in Angular 2?

I'm trying to animate items swapping in a list. So when a user click on item A and then on item B the swap is animated. Is there a common way to do it? My swap function uses array destructuring assignment like this: swap(item: Item): void { if (this.firstSelectedItem) { this.secondSelectedItem = ite...
SomeAnts
1

votes
1

answer
194

Views

Can this Fast Atomic Lock implementation work?

I have a large data structure that is using striping to reduce lock contention. Right now I am using system locks but 99.99% of the time, the lock is uncontested and futhermore, the amount of time holding the lock is quite miniscule. However, several distinct memory operations are performed while...
Adisak
1

votes
2

answer
1.2k

Views

How to programmatically 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?
eric young
0

votes
0

answer
2

Views

Swapping between two nodes using the given elements which are present in these nodes. Python-3.0 is used for writing code

I have written code but errors are there when I am compiling the code. One error is I am using push function to add new nodes in the list and last_pointer node is working as local node. So every time when I call function, last_pointer is considered as fresh or unnamed node. Another error is in swapn...
ritu agrawal
1

votes
2

answer
2k

Views

How can i return value from one method to another & swapping

I have this public class Mapper implements ScramblerIF { private static String map = 'drsjckpwrypwsftylmzxopqtdo'; public static String charAt(String str) { //char[] chars = str.toCharArray(); int length = str.length(); for(int i=0; i
Dmoney
1

votes
1

answer
4.5k

Views

Swap Elements in a 2D Array C#

I am using C#, I'm fairly new to the language but I have used similar languages before so I understand basic syntax. I have a 2D array of type Object. (X represents what value and Y is what record) It stores two strings in columns 0 and 1 and a MessageBoxIcon in 2 and a MessageBoxButtons in 3. I wou...
YoshieMaster
1

votes
2

answer
658

Views

swap classes on click

I have a list of 6 items that are in a global div (navigationagence) Right now I am able to add a class on click but right now they adds up which means that once my six items are clicked they all end up with the currentagence class. I want to be able to remove the add a class to the clicked item but...
Francis Thibault
1

votes
2

answer
852

Views

Sort vectors within 2D Vectors

I have a problem sorting vectors in 2D vector? I would like to sort them based on their capacity from the largest to the smallest. Example: ROWS {{1,2,3},{1,2},{1,2,3,4,5}} it should be sorted as ROWS.capacity(); // ROWS {{1,2,3,4,5},{1,2,3},{1,2}} The following is part of the code i did until now...
NIX
1

votes
1

answer
280

Views

Swap array Item with condition

I have the situation to swap array with condition.My array is plotted bellow. pid => like primary key in mysql so it may loose it order type=> type indicates, product type.array having 3 type of products. Name=> Simply indicates product name First I tried solution in mysql, But I didn't got any good...
Gowri
1

votes
1

answer
677

Views

How can I call eglSwaptInterval using AndroidNDK?

I need to set the interval in eglSwapInterval to 0 for my application, however I need to know the EGLDisplay for this. Is this call supported in Android, and if so how can I call this using GLSurfaceView (or do I need to call this from the native code?)
lost_bits1110
1

votes
2

answer
552

Views

.delegate img src= and fading

I have this function. $('.anythingSlider').delegate('img','click', function(){ $('#largeImage').attr('src',$(this).attr('data-image')); }); I would like to have the img fade out/in when the thumb is clicked and the img src is swapped. I've tried $('.anythingSlider').delegate('img','click', function...
mkrisch
1

votes
2

answer
3.2k

Views

Copy values of a mp3 tag to another tag for a batch of MP3 files

I have a large MP3 directory and somehow the values of album tags (or album names) of the files (for all of them, hundreds) are actually the values of artist tags (or artist names) and vice-versa. Now I have to copy the values from each other so that they are swapped for each and every single file...
amar
1

votes
2

answer
1.3k

Views

A better Swap divs technique

So here is what I am trying to accomplish. First I will have about 8 or so images on the left side of the page and about 8 divs on the right side. Now when a person clicks on an image I want the current div to 'hide' and be replaced with the other div that that image is linked to. For example: I c...
user996185

View additional questions