Questions tagged [contains]

The "contains" operator/method is used to determine if an entity collection contains an element with a particular property.

The contains operator/method is used to determine whether one (or more) of the entities in an entity collection has a particular property.

3008 questions
21
votes
13 answers

Javascript array contains/includes sub array

I need to check if an array contains another array. The order of the subarray is important but the actual offset it not important. It looks something like this: var master = [12, 44, 22, 66, 222, 777, 22, 22, 22, 6, 77, 3]; var sub = [777, 22,…
Victor Axelsson
  • 1,420
  • 1
  • 15
  • 32
21
votes
4 answers

Excel formula to search if all cells in a range read "True", if not, then show "False"

Using an excel formula to search if all cells in a range read "True", if not, then show "False" For example: A B C D True True True True True True FALSE True I want a formula to read this range and show that in row 2, the was a…
user3384215
  • 213
  • 1
  • 2
  • 4
20
votes
5 answers

Android: How to check if a rectangle contains touched point?

I would try to develop an application in which I can draw a planimetry. So, each room has got its own ID or name and, if I touch a room, I want to show a Toast Message with that ID or name. The problem is how check if and which path is touched!! I…
kinghomer
  • 3,021
  • 2
  • 33
  • 56
20
votes
4 answers

Check whether a map contains all contents of another map

I am trying to check whether a map contains all contents of another map. For example, I have a mapA which is a Map> and the elements are: "1" -> ["a","b"] "2" -> ["c","d"] another mapB which is also a Map>,…
Atwood Wang
  • 201
  • 1
  • 2
  • 4
20
votes
3 answers

Element is present but `Set.contains(element)` returns false

How can an element not be contained in the original set but in its unmodified copy? The original set does not contain the element while its copy does. See image. The following method returns true, although it should always return false. The…
wehnsdaefflae
  • 826
  • 2
  • 12
  • 27
20
votes
5 answers

Why do we have contains(Object o) instead of contains(E e)?

Is it to maintain backwards compatibility with older (un-genericized) versions of Collection? Or is there a more subtle detail that I am missing? I see this pattern repeated in remove also (remove(Object o)), but add is genericized as add(E e).
Vivin Paliath
  • 94,126
  • 40
  • 223
  • 295
20
votes
3 answers

List.Contains and T[].Contains behaving differently

Say I have this class: public class Animal : IEquatable { public string Name { get; set; } public bool Equals(Animal other) { return Name.Equals(other.Name); } public override bool Equals(object obj) { …
nawfal
  • 70,104
  • 56
  • 326
  • 368
20
votes
1 answer

XPath with multiple contains on different elements

Is it possible to have XPath expression with multiple contains of different element values? XML Kerry Packer
Crown
TeaCupApp
  • 11,316
  • 18
  • 70
  • 150
20
votes
5 answers

Using Linq to do a Contains with multiple values

I have a medication table that I'm looking for certain drug names, but I need to search for multiple names. Here is where I currently am with it. string[] names = new string[2]; names[0] = "apixaban"; names[1] = "desirudin"; var meds = (from m in…
Jhorra
  • 6,233
  • 21
  • 69
  • 123
19
votes
1 answer

Hibernate query: does a Set contains a certain Object?

I have two Hibernate data object. The first is a User (with unique id, username etc.) and the second is the class Collaborateable. Between this two there is a n-to-m relation (implementet with Sets). That means, a User works on many Collaborateables…
sockeqwe
  • 15,574
  • 24
  • 88
  • 144
19
votes
4 answers

Get only Whole Words from a .Contains() statement

I've used .Contains() to find if a sentence contains a specific word however I found something weird: I wanted to find if the word "hi" was present in a sentence which are as follows: The child wanted to play in the mud Hi there Hector had a hip…
Jay
  • 4,873
  • 7
  • 72
  • 137
19
votes
4 answers

In python, how can I print lines that do NOT contain a certain string, rather than print lines which DO contain a certain string:

I am trying to condense a very large log file, and to do so, I must eliminate every line which contains the string "StatusRequest" and "StatusResponse", while printing the other lines w/o this string. The code I have so far is as follows (to run…
user3877194
  • 191
  • 1
  • 1
  • 3
19
votes
2 answers

How does contains() in PL-SQL work?

Have a lot of unnecessary results using contains() method in my query. Don't tell me to use like or something else. It is hardcoded and couldn't be changed.
Artsiom Anisimau
  • 1,139
  • 3
  • 11
  • 26
19
votes
4 answers

Does array element contain substring?

I'd like a function that checks whether an array's items contain a string. As such: array(1 => 'Super-user', 'Root', 'Admin', 'Administrator', 'System', 'Website', 'Owner', 'Manager', 'Founder'); And then checking for admin12 should return true as…
Isaiah
  • 1,852
  • 4
  • 23
  • 48
18
votes
2 answers

HQL Equivalent of SQL Contains

I'm trying to write an HQL query to select objects which contain an object in a child collection. Example: Contest Object ContestID ContestName RequiredCountries -> one to many collection of Country objects Country Object CountryCode …
Brian
  • 761
  • 2
  • 10
  • 25