Questions tagged [swap]
Changing position of two items.
2,501
questions
0
votes
0
answers
11
views
VmRss for a process is growing linearly and not stabilizing. Can it be a memory leak?
So I have a alma OS 64-bit linux based application. My application has various process out of which one of them, let's call it "VoicemailApp" is showing linear increase in VmRss over a ...
1
vote
1
answer
61
views
What is wrong with my assembly code that is trying to swap each element of an even array with the element that is next to it?
I am taking a beginner assembly code class and I can't figure out what is going wrong. I moved arr+1 (the second element in the array arr) into EDX at the end just to check if the correct value is ...
0
votes
0
answers
17
views
ubuntu hibernate enabling by increasing swap size
I am using ubuntu 22.04 LTS. I am having an issue with hibernation - mainly when i left my laptop on with many tabs on browser open and pycharm is on after a while it does not open up. The screen ...
1
vote
4
answers
114
views
segmentation fault in C linked list
I have written a code in C about swapping adjacent nodes in a linked list, but the code is not running in VSCode due to a segmentation fault. I don't know what's causing it and the code is giving ...
-1
votes
0
answers
36
views
Why does this affect the variables in the main, but not print the cout? [duplicate]
So I have a swap function which have pointers as parameters. I understand the correct way to use the function is with swap(&n1, &n2). However, for this case I'm learning the difference between ...
0
votes
1
answer
48
views
Swap the contents of two selected cells in google sheets
I am an elementary music teacher and trying to create a seating chart in google sheets. I have 29 sections to manage! I often want to change the seating chart and looking for a streamline way of doing ...
0
votes
1
answer
96
views
What happens in the memory when C++'s move semantics is used?
I am trying to understand C++'s move semantics, move constructor, move assignment operator, std::move().
Let's consider the following example:
#include <iostream>
void swapWithMove(int& a, ...
1
vote
1
answer
34
views
Swap start_time with end_time (vice versa) in a table using R
I am dealing with a bike sharing data set and in its raw data, the start_time has been keyed in with the end_time and vice versa. start time is later than end time
Is there a way I can swap the two ...
3
votes
2
answers
163
views
How can I order a vector using another vector?
This question is similar to the one posed here however, this answer does not work for my question and it is slightly different.
What I am trying to do would best be shown in code:
//this would be a ...
0
votes
0
answers
11
views
Destruct twice after reset on shared pointer
Here the source code :
unique_lock<mutex> lock(_activeFQDNMutex);
activeFQDNs.swap(shadowFQDNs);
shadowFQDNs.reset(new TrieRegexInterface());
After reset, there is a core file, ...
0
votes
1
answer
43
views
Swap Procedure in MIPS
enter image description here
enter image description here
I'm learning MIPS in a CO course, I encounter the swap procedure in MIPS.
I'm wondering that if the load word and store word just load and ...
0
votes
0
answers
24
views
Why do elements end up outside the grid instead of swapping?
There is a grid which has a puzzle where the squares are to be swapped by dragging and dropping in order to recreate an image that is shown next to/below the grid. But when the user drags and drops a ...
-2
votes
4
answers
83
views
Garbage value when swapping array with memcpy()
I am trying to make a generic swap function using memcpy() in C. I am getting a garbage value when I try to swap arrays.
This is code below:
#include<stdio.h>
#include<string.h>
typedef ...
0
votes
0
answers
35
views
How Microk8s works with Swap Partition
Since the Kubenetes Version 1.27, kubelet doesn't work with Swap Partition enabled machine. How the microk8s handles it?
I understand that minikube creates a virtual environment and configures the ...
1
vote
2
answers
38
views
I implemented a quicksort in Java and it works properly but i dont understand the second swap in the partition function?
private static int partition(int[] array,int links, int rechts)
{
int pivotelement = array[links]; //pivotelement on the left
int i = links; // links means ...
0
votes
0
answers
76
views
Can not disable swap in Ubuntu 20.04 to work with kubelet
I was working on setting up a simple kubernetes Cluster in my Local Network. The setup is simple,
One Master Node and one Worker node. But the thing is the latest version of kubelet does not work with ...
0
votes
1
answer
53
views
npm run build does not consume swap memory on centos and errors heap out of memory
I run npm run build give memory issue like below:
# npm run build
> fuse@9.0.0 build
> ng build
93% after chunk asset optimization SourceMapDevToolPlugin main-es2015.js generate SourceMap
<-...
0
votes
3
answers
79
views
Move all zeroes to the end of an array with the order of the elements preserved
Can anyone tell me what have I done wrong in this code ?
In this approach, I traverse the array and, as soon as I find a 0 element, I traverse to the right of the 0, and swap it with the 1st non-0 ...
0
votes
0
answers
20
views
Total Return Swaps
I am trying to understand better Total Return Swaps and how they are priced (I have heard about projection-based and accrual-based models), can any body recommend good material to read (books, ...
0
votes
1
answer
208
views
How to swap trc20 to trx with Python in one wallet address?
I need to swap(change) part of my trc20 asset to trx in my Tron wallet. Consider i have some data like this:
public_key="AAA"
private_key="PPP"
trc20_address="...
0
votes
2
answers
47
views
How to swap the position of siblings in xml using xmlstarlet
I have the following xml file that I would like to swap the positions of the two siblings ("firstname" and "surname"):
From:
<?xml version="1.0" encoding="utf-8&...
0
votes
0
answers
29
views
How to improve the performance of random data lookups on an SSD disk when using mmap?
When using mmap to map a file in Linux, a memory pointer is returned. If a byte is read from this pointer, Linux will read the entire page (usually 4096 bytes) containing that byte from the disk. This ...
0
votes
0
answers
31
views
Array swap elements using Destructuring concept in JavaScript [duplicate]
I'm trying to learn swapping the elements in the array using destructuring concepts in javascript.
var arr = [1, 2, 3]
[arr[2], arr[1], arr[0]] = arr
console.log(arr);
I thought the console will ...
0
votes
1
answer
38
views
Hi I'm a C newbie. (swap the row of matrix)
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void swap_mat(int** ppMat, int i, int j);
int main(void) {
int mat[][3] = { {2,4,6},{8,10,12},{14,16,18} };
for (int i = 0; i < ...
1
vote
1
answer
38
views
Swapping multiple instances of two characters in a string
I'd like to find, if possible, a more succinct or elegant way to swap every occurrence of two specific characters in a string, but still readable and easy to understand, i.e. something akin to a, b = ...
0
votes
0
answers
30
views
"Issue with Inverting Binary Tree using Python's Swap Operation"
last night I was solving some BST problems on LeetCode, and I encountered a minor issue with this problem: Invert Binary Tree. (https://leetcode.com/problems/invert-binary-tree/description/)
As I was ...
-1
votes
2
answers
69
views
Swap operation with inline function
#define INLINE static inline __attribute__((always_inline))
INLINE void swap(int a, int b){
int tmp = a;
a = b;
b = tmp;
}
int main(){
int x = 10;
int y = 20;
swap(x, y);
...
19
votes
0
answers
548
views
Why does std::vector::swap have a different noexcept specification than all other container swap functions?
I noticed that the std::vector container's swap function has a different noexcept-specification than all other containers. Specifically, the function is noexcept if the expression
std::...
0
votes
0
answers
61
views
Regular swap contract [SOLIDITY]
I am trying to create solidity contract to swap Goreli ETH to Link, but any transaction i try to make it fails, can any one spot an issue with it ?
// SPDX-License-Identifier: MIT
pragma solidity 0.8....
1
vote
1
answer
62
views
Swap alternate elements in an array using recursion?
I wrote the below code to swap alternate elements in an array {eg. (1,2,3,4,5)-->(2,1,4,3,5) }. I wanted to try it using recursion.
#include <iostream>
using namespace std;
void print(int *a,...
1
vote
2
answers
76
views
Why regular swap works with a pointer-to-pointer variable?
I know the difference between these two functions: Swap(int *x, int *y) vs Swap(int **x, int **y).
But, I'm not sure how this kind of code works.
How is it possible to swap the address which the ...
-1
votes
3
answers
91
views
How to swap two different length group of variable in array?
How to swap two different-length groups of variables of the same array in the same array? Even if I need the code in C#, in the meantime the theoretical procedure would be enough for me.
I've already ...
1
vote
1
answer
53
views
Why does one variation of my doubly linked list node swap work while another almost identical variation does not on adjacent nodes?
I'm practicing linked data structures in Python. One problem I'm working on is a method to swap two nodes within a doubly linked list without just moving data. So no node1._data=node2._data or ...
3
votes
1
answer
131
views
C.83: What's the rationale behind the C++ core guidelines recommending defining your own swap function anytime you have a value-like type?
Referring to this
I'm trying to understand when to create a custom swap() function for my classes. Researching it previously, it looks like ever since c++11 the std::swap() function has used move ...
0
votes
0
answers
49
views
How to swap the positions of two siblings: using xmlstarlet
How do I swap the positions of two siblings:
From:
<article>
<name>
<firstname>John</firstname>
<surname>Pettterson</surname>
</name>
</...
0
votes
1
answer
60
views
Clojure update nested map inside atom
I have an atom like this, inside a let:
(let [scors (atom {:one {:year-one [] :year-five [] :year-ten []}
:two {:year-one [] :year-five [] :year-ten []}
:...
-2
votes
1
answer
144
views
Given the list {12 30 40 0 47}, how many swaps will occur during the outer loop execution (i = 3)? [closed]
So I have a class where we are taught how to code in Java. We were learning about sorting algorithms like Bubble, Merge, Insertion or Quick sorts and their time complexities. In a quiz, I got this ...
0
votes
1
answer
35
views
cs50 weak 4 reflect problem, a problem in the output where the first row of each column is always zeros
When running cheak50, I encounter some errors. when I test the code on an image, it works correctly and reflects the image. The issue is that the first row of each column always contains zeros, ...
0
votes
1
answer
53
views
cs50 reflect code is failing. values are not in there right place
I cant find a way to fix these two errors despite that the pic reflects correctly when i test it by myself.
this is the error
testing with sample 1x3 image
first row: (255, 0, 0), (0, 255, 0), (0, 0, ...
-2
votes
1
answer
39
views
How To swap arrraylist element without using any inbuilt function? [duplicate]
Could someone assist me in solving this problem? I want to swap two elements of my ArrayList, and I don’t want a function from the library to do it for me.
ArrayList<Integer> al=new ArrayList<...
3
votes
1
answer
38
views
What is the new content of an array if I redefine a value of an array inside that same array in C?
What are the contents of a[]?
int a[ ] = {4 , 9, 1, 8, [0]=5, 7};
I tried printing it out with:
int main () {
int a[ ] = {4 , 9, 1, 8, [0]=5, 7};
for(int i = 0; i < 10; i++) {
...
0
votes
0
answers
27
views
Tkinter - unable to swap frames with grid-method widget placement
I have an application that I wish to be able swap (a number of) Tkinter frames such that only one frame is visible. The frames must be able to contain widgets placed using the grid-method. However, my ...
0
votes
2
answers
55
views
Unexpected behaviour when swapping elements in C list
Homework from uni, tl;dr is that we had to create functions: swap(args), sort(args), max(args) where sorting is in descending order.
Function that is the core of the problem is swap. Array arr is of ...
1
vote
2
answers
78
views
Swapping Array elements call by reference
I had to swap array elements with call by reference to reduce the lines of code in my bigger project, and I am successful in swapping them but this code gives a bunch of warnings, how do I do this ...
-7
votes
1
answer
100
views
Algorithm formation in c language [closed]
SO i am trying to make a algo that shift element in array when ever 2 is found in array
input 3 4 2 9, output 4 2 9 0 this output is needed , I have tried some sort of code but quite confused cause ...
1
vote
0
answers
70
views
Change a csv file to shopify format
I am an absolute beginner when it comes to coding. I have the problem that I get a CSV file from my supplier that is not Shopify compliant. Now I have to change it so that I can upload it. I know how ...
0
votes
1
answer
60
views
std::is_swappable_v is false on a swappable class template
I'm trying to write a swappable class template, S<T>. I'd like S<T> and
S<T&> to be swappable if T is swappable (e.g. S<int> should be swappable
with S<int&>). So ...
0
votes
0
answers
305
views
New ubuntu installation (Ubuntu 22.04.2 LTS) constantly causing apps to crash
After having a number of issues with applications crashing and worries about my hard drives being corrupt (I kept getting kernel panic signals at startup unless I started in recovery mode), I decided ...
0
votes
3
answers
76
views
Program to reverse string truncates result
I am a noob programmer. I have written this program in C that is to take in a string input and then reverse it. However when it prints the result, it gives some garbage values and a truncated version ...
0
votes
0
answers
32
views
output of resolvectl query swaps
Why does the order of entries randomly swap when running resolvectl query?
resolvectl query fedoraproject.org
fedoraproject.org: 2a05:d01c:c6a:cc01:269:da52:9ae1:43e6 -- link: enp6s0
...