Questions tagged [swap]

Changing position of two items.

Act of rearranging the locations of two items such that the first item now occupies the place of the second and the second item now occupies the place of the first.

2503 questions
0
votes
3 answers

How to update a reagent atom filtering in a nested vector of maps in Clojure

Let's say I have a reagent atom with a vector of maps like this: (def my-atom (reagent/atom {:id 256 :name "some name" :lines [{:code "ab43" :name "first nested name" :quantity 4} …
0
votes
1 answer

Can queues be used to swap adjacent nodes of a linked list?

I was trying to swap the adjacent nodes of a linked list using queues. Below is the code: class Solution { public ListNode swapPairs(ListNode head) { Queue q1 = new LinkedList<>(); Queue q2 = new…
msbtech
  • 21
  • 3
0
votes
2 answers

I don't understand why i get segmentation fault with a function that should only swap 2 values in a struct

the read_file functin works smoothly. but whenever i call the reorder function i get the segmentation fault. in this code i define a struct containing 2 coordinates( x and y ) and save a file containing a bunch of coordinates in the "fleet" array,…
0
votes
0 answers

How does the comma operator work with assigning to multiple variables?

The following piece of code #include #include using namespace std; int main() { // your code goes here string a="abc", b="xyz"; a,b = a+b, b+a; cout<
illla
  • 95
  • 7
0
votes
1 answer

How can I prevent oom-kill without increasing RAM

I have 256MB Orange Pi Zero that I want to run OctoPrint on. It starts and run for some time, then it gets killed because of out of memory. I can't add more RAM so I tried to increase swap size. I added 1GB but it doesn't help. Also I don't…
Krzysiek
  • 185
  • 1
  • 10
0
votes
1 answer

swap the columns of multidimensional array in R

I would like to swap the values of the 2nd and 3rd columns of the following array. dat1=structure(1:18, .Dim = c(2L, 3L, 3L)) > dat1 , , 1 [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 …
Uddin
  • 754
  • 5
  • 18
0
votes
1 answer

Swapping pointers: equivalent of `std::unique_ptr::swap`

I'm not sure how to translate C++ std::unique_ptr::swap into Go. I am using std::unique_ptr::swap in C++: std::unique_ptr maskA{new bool[num]}; std::unique_ptr maskB{new bool[num]}; // ... maskA.swap(maskB); // Swap…
Megidd
  • 7,089
  • 6
  • 65
  • 142
0
votes
1 answer

mysql using swap space even lot of RAM is free

Here is my my.cnf symbolic-links=0 user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp log-error =…
0
votes
1 answer

Swapon --show does not update gb size when resizing disk

I was wondering about something, I used AWS to resize a swap partition on an EC2 instance. When I ssh into the instance and use the command swapon --show in the console I still get the old GB value of the partition, however, if I use lsblk for…
Benny
  • 839
  • 16
  • 32
0
votes
1 answer

Randomly swap a certain amount of entries in two different columns in a data frame in R

I have simulated two vectors from a binomial distribution. Both vectors have a different probability of success. Now I have merged them together into a data frame and I need to swap 50 column entries randomly (i.e. put 50 random entries from B into…
0
votes
2 answers

How to swap two values of different data types in C++

Is there a way I can swap two values (a and b), which are of different data types (e.g. int and float) without using the built-in swap() function in C++?
Pius84
  • 17
  • 6
0
votes
0 answers

Why the swap of these two strings doesn't take place and provides the same output?

I am new to these pointers concept. I would like to know why doesn't the code below swaps both the string (or) atleast the first letter of the string. Program: #include void swap(char* s1,char* s2) { char* temp=s1; s1=s2; s2=*temp; } int…
Krithick S
  • 408
  • 3
  • 15
0
votes
3 answers

Despite everything looks fine, values are not swapped

I wanted to write a function to swap two integers. Despite everything looks fine, values are not swapped. Here is my code: #include using namespace std; void mySwap(int a, int b) { int temp; temp = a; a = b; b = temp; } int…
VIVID
  • 555
  • 6
  • 14
0
votes
2 answers

Given an array of integers, needing run operations on a Max_Heap. Getting error "segmentation fault", Any ideas? (C++)

This is one of my first posts on here so please bear with me. I am working on an assignment and have looked at various sources to create and solve this problem. Prompt for problem I have written the max_heapify, print, build_heap, and delete_root…
Morgan
  • 9
  • 2
0
votes
2 answers

Jquery Image swap on hover Gallery

Hi there Got this sorted now Been trying all different JQuery Plugins and JS tutorials all day trying to make a image swap on hover gallery like on amazons product page, when you hover over the thumbnail and it comes up on main image. I can't get…
Joseph
  • 1
  • 3
1 2 3
99
100