Questions tagged [containskey]

80 questions
0
votes
1 answer

Why is Dictionary.ContainsKey returning False when the key is an int[]?

I'm working on some map generation, but I have run into an issue. Below is the simplified code. It returns False whilst it should return True. static Dictionary map = new Dictionary(); static bool GenerateMap() { …
Kat9_123
  • 11
  • 1
  • 2
0
votes
1 answer

Java Map.containsKey(ArrayList) returns false in one line and true in the next

I have a HashMap, Integer>. I'm removing objects from the Map before replacing them, so I'm trying to avoid put calls which already have the key present in order to keep the Map size the same (for a steady-state Evolutionary…
0
votes
0 answers

Key cannot be found in nodes

It is my understanding that the NAME of a node in a TreeView is the same as the KEY. If so, I don't understand why ContainsKey (fyi: ContainsKey requires string) does not return the correct result: MessageBox.Show(tv_Projects.SelectedNode.Name);…
Daniel227
  • 127
  • 9
0
votes
1 answer

android java --key is same but containsKey return false

I have to put values in LinkedHashMap. (because, I want sorting and determinig if there are values already) I thought containsKey return true if String values are same like temp and temp2. However, testMap.put(temp2,8); is running. I don't know…
현도연
  • 65
  • 1
  • 7
0
votes
1 answer

Why isn't my hashmap returning a word count?

I am creating a hashmap that does linear probing to find an index for the key. If the key is already in the index, I want to increase its value, not add one to a new index. For example, if I get a word count for the string "five, five, five" my…
0
votes
1 answer

TreeMap#containsKey return false just after put

I know this question has been treated before but I've read questions and tried to fix my own with no result, I think I'm missing something with the TreeMap or Map implementation... if(arme != null){ if(!hommesArmes.containsKey(arme)){ …
0
votes
1 answer

HashMap containsKey always returns false for same string

I am parsing from a file where I have city names and distances to other cities in this format: "San Antonio" "San Francisco" Washington "San Francisco"--Weed [305] "San Francisco"--"Wisconsin Dells" [2189] Washington--"San Jose" [2909] I think…
Slayahh
  • 373
  • 4
  • 14
0
votes
1 answer

Update the count of the purchases of products using HashMap

I am reading a .txt file and it needs to be able to update the entry with the products key 5020 in product map, increasing the count of purchases by 2. So far I am able to do it by the costumer map, but I need to make another display by the product…
Atheya
  • 99
  • 10
0
votes
0 answers

HashMap entry has been lost

I don't understand why this code: import java.util.HashMap; import java.util.Map; import java.util.Objects; public class Main { public static void main(String[] args) { Map map = new HashMap<>(); Person person =…
k13i
  • 4,011
  • 3
  • 35
  • 63
0
votes
2 answers

HashTable getcontainsKey does not work

I don't understand why this simple method does not work My class AccessChecker has the attribute Hashtable> permissions = new Hashtable>(); with two methods: First method If I put…
user1450740
  • 731
  • 10
  • 26
0
votes
1 answer

containsKey method of TreeMap returns false despite that the key is already in the Map

I try to write a program that counts all the words in text file. I put any word that matches the patterns in TreeMap. The text file I get through args0 For example, the text file contains this text: The Project Gutenberg EBook of The Complete Works…
Asaf
  • 107
  • 1
  • 12
0
votes
2 answers

Java util hashmap containsKey()

I have been having some trouble using the function containsKey. I wrote a small program to show where I am expecting containsKey to give me a different result: HashMap> hashMap; HashMap
Marnix
  • 3
  • 3
0
votes
0 answers

Why is my HashMap.containsKey(myKey) always returning false?

I have a program with three objects one of them is a 6 variable object that represents the columns in a ResulSet. The other two have 3 varialbes and they match up with the first and last 3 from my other 6 variable object. I have a List<6 Var object>…
0
votes
0 answers

containsKey is returning true while expecting false

import java.util.HashMap; public class Chapter1_Problem_1_1 { public static void main(String[] args) { String str = "bacdee"; int j = 0; for(int i=0; i< str.length(); i++) { char ch = str.charAt(i); …
sbolla
  • 671
  • 3
  • 22
  • 39
0
votes
1 answer

TreeView ContainsKey not working during add loop

I've been reviewing the documentation and reading posts on the subject but still have not found the answer currentTREENODE = treeviewResults.TopNode For Each item As String In incomingList If…
mreinsmith
  • 154
  • 3
  • 14