swap

How do I make a constexpr swap function?

对着背影说爱祢 提交于 2019-12-06 13:57:27
I'm making my own String View class for learning purposes, and I'm trying to make it 100% constexpr. To test it, I have a member function that returns an hash value. I then construct my string view in a switch statement and call that same member function, if it passes, that member function has fullfiled its purpose. To learn, I'm using / reading / comparing my implementation with Visual Studio 2017 latest update std::string_view , however, I've noticed that, despite swap being marked as constexpr , it does not work, nor in Visual Studio, nor in g++. This is the piece of code that does not work

Programmatically swap two JPanels in JFrame

落花浮王杯 提交于 2019-12-06 13:36:10
I am trying to accomplish the above functionality, and am having little success. I am using GridLayout with 2 columns and 2 rows to show the user a puzzle-like game, where there are 4 (200x200 pixel) JPanels (3 colored, 1 default bgColor) which fill the whole contentPane. Clicking on a colored panel resolves in an assessment if the panel is next to the gray panel. If so, they should swap. I have accomplished every step to the last one, where they swap. Here's the code: public class MainClass extends JFrame { //Generated private static final long serialVersionUID = 4710628273679698058L; private

How do I swap 2 elements in a list [duplicate]

佐手、 提交于 2019-12-06 07:48:32
This question already has answers here : Closed 7 years ago . Possible Duplicate: Swap two items in List<T> Edit: Maybe this will work for getting the 'b' value? for (int i = 0; i < inventory.Count; i++) { if (inventory[a].ItemRectangle.Intersects(inventory[i].ItemRectangle)) { itemB = inventory[i]; } } Edit: Here's my progress. Item itemA; Item itemB; int a = -1; int b = -1; if (a != -1 && b != -1) { itemA = inventory[a]; itemB = inventory[b]; Swap(ref itemA, ref itemB); inventory[a] = itemA; inventory[b] = itemB; } And here's is where I'm getting the 'a' value. if (item.ItemSelected == true)

Function for swapping 2 elements in an array doesn't work

空扰寡人 提交于 2019-12-06 07:48:26
问题 I am new with C# and I can't understand why this code doesn't work. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { char[] sw = "ab".ToCharArray(); swap(sw[0], sw[1]); string end = new string(sw); Console.Write(end); } static void swap(char a, char b) { char temp = a; a = b; b = temp; } } } What I expect on console is "ba" but I get "ab". I was

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

不问归期 提交于 2019-12-06 03:31:29
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 asynchronous behavior of the graphic stack, many things can get the length of the graphic calls to jitter

swap temporary tuples of references

不羁岁月 提交于 2019-12-06 01:43:25
问题 I'm writing a custom iterator that, when dereferenced returns a tuple of references. Since the tuple itself is ephemeral, I don't think I can return a reference from operator*(). I think my iterator makes sense semantically, since it has reference semantics, even though operator* returns a value. The issue is, when I try to call std::swap (or rather, when std::sort does), like below, I get errors because the swap expects l-values. Is there an easy fix to this problem? #include <vector> class

How to change span color on div hover

 ̄綄美尐妖づ 提交于 2019-12-06 01:35:42
I am trying to change color of span on div's hover How to make the red hamburger button (which is span) to change the color to black on div's hover PS: Right now it does it on span's hover JSFiddle: https://jsfiddle.net/bjjbqct8/ .mobile-nav-toggle { height: 50px; width: 35px; margin-right: 31px; background: #ddd; display: flex; align-items: center; cursor: pointer; } .mobile-nav-toggle span, .mobile-nav-toggle span::before, .mobile-nav-toggle span::after { border-radius: 2px; content: ""; display: block; height: 6px; width: 100%; background: rgba(177, 66, 66, 0.8); position: relative; }

Embed content of a html file to another html page using the Ionic framework?

自作多情 提交于 2019-12-06 00:31:59
I”m currently creating a website using the Ionic framework that has a sidebar on the left side. Users can click on an item to go to another page of the website. Now I have to copy the code of the sidebar to every page and that's useless and not the way to go. So my question is if it is possible to "embed" a html page in a specific section of another page. For example I could have my sidebar be "static" and load in a login.html file in a specific div. And having one html file with all the pages would be very hard to maintain and organise. Is that possible in some kind of way? EDIT: As

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

让人想犯罪 __ 提交于 2019-12-06 00:14:08
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).attr("name"); var imagepath = "images/img_"+theirname+".jpg"; var headerpath ="images/header_"+theirname

Swap alt keys functionality

前提是你 提交于 2019-12-05 22:20:46
I need to swap Alt keys functionality in Windows 7. A big company needs that for old people that were writing on typewriters, which had diacritic characters key on the left side, but Win7 which they are working on now has right Alt for this purpose. Two days of research brought me to a driver solution. I need source code for original Windows 7 drivers (two .sys files seem to be the keyboard drivers), and possibily to modify them in Windows DDK. Or I need to make an additional driver that would work with the default ones. As I can see, the solution would be in C or C++. But what way do I have