equals

C# - compare two SecureStrings for equality

喜夏-厌秋 提交于 2019-12-02 17:55:24
I have a WPF application with two PasswordBoxes, one for the password and another for the password to be entered a second time for confirmation purposes. I was wanting to use PasswordBox.SecurePassword to get the SecureString of the password, but I need to be able to compare the contents of the two PasswordBoxes to ensure equality before I accept the password. However, two identical SecureStrings are not considered equal: var secString1 = new SecureString(); var secString2 = new SecureString(); foreach (char c in "testing") { secString1.AppendChar(c); secString2.AppendChar(c); } Assert

How to compare equality of lists of arrays with modern Java?

陌路散爱 提交于 2019-12-02 17:50:08
I have two lists of arrays. How do I easily compare equality of these with Java 8 and its features , without using external libraries? I am looking for a "better" (higher-level, shorter, more efficient) solution than brute-force code like this (untested code, may contain typos etc, not the point of the question): boolean compare(List<String[]> list1, List<String[]> list2) { // tests for nulls etc omitted if(list1.size() != list2.size()) { return false; } for(i=0; i<list1.size(); ++i) { if(!Arrays.equals(list1.get(i), list2.get(i))) { return false; } } return true; } Or, if there isn't any

How to check if two ranges value is equal

痴心易碎 提交于 2019-12-02 15:32:34
问题 I want to merge cells in columns, if there is the same value in whole row. Eg. If A1:G1 range is the same as A2:G2 I want to merge A1:A2 cells, B1:B2 to G1:G2. With my code below I get run time error 13: type mismatch. I'm assuming, that problem is with checking equality of two ranges. Dim i As Long, j As Long, row as Long row = Cells(Rows.Count, 6).End(xlUp).row For i = row To 7 Step -1 If Range(Cells(i, 7), Cells(i, 24)).Value = Range(Cells(i - 1, 7), Cells(i - 1, 24)).Value Then For j = 7

Overriding equals for CopyOnWriteArraySet.add and remove

大兔子大兔子 提交于 2019-12-02 14:58:14
问题 I have classes like below class A { @Override public boolean equals(Object other) { return true } } Class B extends A { } Class C extends A { @Override public boolean equals(Object other) { if ((other != null) || (other instanceOf B)) return false; } } In my main() I have this following code Set<A> mySet = new CopyOnWriteArraySet<A>(); mySet.add(C); I want mySet to contain C at this point mySet.add(B); // #1 I want mySet to contain C & B at this point mySet.remove(B); // #2 I want mySet to

Check if bash variable equals 0 [duplicate]

好久不见. 提交于 2019-12-02 14:19:47
This question already has an answer here: Comparing numbers in Bash 8 answers I have a bash variable depth and I would like to test if it equals 0. In case yes, I want to stop executing of script. So far I have: zero=0; if [ $depth -eq $zero ]; then echo "false"; exit; fi Unfortunately, this leads to: [: -eq: unary operator expected (might be a bit inaccurate due to translation) Please, how can I modify my script to get it working? Looks like your depth variable is unset. This means that the expression [ $depth -eq $zero ] becomes [ -eq 0 ] after bash substitutes the values of the variables

How to properly implement equals in Java

断了今生、忘了曾经 提交于 2019-12-02 12:45:15
I need to implement the equals method in some class A. Class A has an orderer collection of Enum type, and the behaviour I want to achive is that equals returns true for two instances of Class A that have exactly the same Enum values in the collection (in exactly the same positions of the collection). As I'm new to java, I'm having problems with this, and I dont know how to properly implement equals or the hashcode methods, so any help would be good :) If you're using eclipse (netbeans has similar features, as do most java IDEs), you can simply got to the "Source" menu, and choose "Generate

Java HashMap return value not confirming with my understanding of equals and hashcode

不羁的心 提交于 2019-12-02 12:43:46
问题 The output of the following code sample is: {1--e=e2, 2--e1=e1} package com.sid.practice; import java.util.HashMap; import java.util.Map; public class InputOutputPractice { public InputOutputPractice() { } public static void main(String[] args) { Employee e = new InputOutputPractice().new Employee(1, "e"); Employee e1 = new InputOutputPractice().new Employee(2, "e1"); Employee e2 = new InputOutputPractice().new Employee(1, "e2"); Map m = new HashMap(); m.put(e, "e"); m.put(e1, "e1"); m.put(e2

Trouble over riding and using equals method in java

拈花ヽ惹草 提交于 2019-12-02 12:18:08
问题 I'm have problems trying to figure out how to compare selectedRadio between AM FM AND XM so that I can determine which one it is currently on and then return the station of the particular radio. I know that i need the equals method i'm just not sure the correct way to use it to get the result i'm looking for. public class AutoRadioSystem { private Radio selectedRadio; private AMRadio radioAM; private FMRadio radioFM; private XMRadio radioXM; //I'm not sure if this is the correct way to do

Syntax error when asking if a variable equals another variable in batch

拜拜、爱过 提交于 2019-12-02 11:14:07
问题 Here is my code: if %magic%==%weakness% set /a damage=%random%*3/32767+12 if %magic==%resistance% set /a damage=%random%*3/32767+5 echo Your attack does %damage% damage. I keep getting a syntax error when I run this. What am I doing wrong? 回答1: You should always use quotes around your variables or use delayed expansion, to avoid problems when one or both variables are empty. Btw. in the second line you missed one percent if "%magic%"=="%weakness%" set /a damage=%random%*3/32767+12 if "%magic%

scheme word lists eq?

不问归期 提交于 2019-12-02 09:23:41
i've got a problem: I need to find if list equal to the second one, for example: (set%eq? '(1 2 3) '(1 2 3)) ===> #t (set%eq? '(1 2 3) '(2 3 4)) ===> #f That examples are correct in my program, but this one is not: (set%eq? (quote ((quote one) (quote two) (quote three))) (quote ((quote one) (quote two) (quote three)))) ====> #f but i need #t what's wrong? this is my program: (define (set-eq? xs ys) (cond ((and (null? xs) (null? ys)) #t) ((null? ys) #f) ((eq? (car xs) (car ys)) (set-eq? (cdr xs) (cdr ys))) ((eq? (car xs) (car (reverse ys))) (set-eq? (cdr xs) (cdr (reverse ys)))) (else #f)))