contains

Why can't I check to see if my array of arrays contains a specific array?

回眸只為那壹抹淺笑 提交于 2019-11-28 14:21:28
I'm trying to check to see if an array of arrays contains an array of Strings. My error message says: "Cannot find an overload for 'contains' that accepts an argument list of type '([([(String)])]), [(String)])'" var allCards = [[String]]() var exp1 = [String]() if !contains(allcards, exp1) { allCards.append(exp1) } What's going on!? Array does not conform to the Equatable protocol, therefore /// Return `true` iff `x` is in `seq`. func contains<S : SequenceType where S.Generator.Element : Equatable>(seq: S, x: S.Generator.Element) -> Bool cannot be used here. You can use the predicate-based

Rotate Rectangle in Java

爷,独闯天下 提交于 2019-11-28 13:55:01
I need to create rectangles that are rotated around their center (so they don't need to be parallel to the axes of the coordinate system). So basicelly each rectangle can be defined by center-X , center-Y , width , height and angle . What I want to do then is to perform calculations on whether certain points are contained in these rectangles or not (so no drawing will be involved). I guess I cant use the Rectangle2D class because these rectangles will always be parallel to the x and y-axis of the coordinate system. Is the only way to get this functionality by writing my own rectangle class or

JQuery :contains function limit to exact match

ぃ、小莉子 提交于 2019-11-28 13:34:54
Using the JQuery :contains function to decide which option on a select is selected from a SESSION variable. The contains function is matching the wrong option as their is an option 'PADI Open Water' and another 'PADI Open Water Scuba Instructor' How do we limit it to match the exact content and no more? $('option:contains("<?php echo $_SESSION['divelevel'];?>")').attr('selected', 'selected'); Try using .filter() , to find the option you want. $('option').filter(function(){ return $(this).html() == "<?php echo $_SESSION['divelevel'];?>"; }).attr('selected', 'selected'); Rocket Hazmat's answer

Arrays and -contains - test for substrings in the elements of an array

◇◆丶佛笑我妖孽 提交于 2019-11-28 13:13:40
I am trying to filter out users that are in a specific group. I got the following output in a variable: Group1 Group2 etc... One group for each line saved in an array. Im trying to filter out only one specific group. But when I use -contains it always says $false , even tho the group is there. My Code: $group = get-aduser -identity name -properties memberof | select-object -expandproperty memberof | %{ (get-adgroup $_).name } $contains = $group -contains "string" $contains is $false even if the array has elements that contain the string... What am I missing? It looks like your misconception

How to SuggestAppend a ComboBox containing a string

倾然丶 夕夏残阳落幕 提交于 2019-11-28 12:44:38
Goal I'd like to have my ComboBox items suggest and append its items when something is contained in them, not just via the StartsWith function. My ComboBox is bound to a DataView which contains clients [ CompanyName ], [ Address ], [ City ] in a long concatenation. I want my users to be able to type in the city and still find the records which matches with all of the fields above. I know this is possible with Infragistics but I don't have that package. Search Term: " Sher " Costco, 123 1st Avenue, Sher brooke Provigo, 344 Ball Street, Sher brooke Sher box, 93 7th Street, Montreal Is this

Collection/Array contains method

左心房为你撑大大i 提交于 2019-11-28 11:30:55
i was wondering if there's contains method for collections/array in EL 2.2 or i will have to make a custom one ? REQUIREMENT : i have a string array, and i want to find if it contains a specific string. CASE : i am looping on list of input checkboxes to render them, and i want to check the current checkbox, if it's value exists in the array of checkboxes. UPDATE : is such method is available in EL? If such method is not available, then please provide your suggestion for best performance method for a string array contains an element. BalusC For a Collection it's easy, just use the Colleciton

Using .Contains() on a property in a list

白昼怎懂夜的黑 提交于 2019-11-28 11:26:55
I have a List of Activity. In the Activity class is an ID property (a Guid for arguments sake). I want to check if this list has an Activity in it with a Guid I have. Rather than this: foreach(Activity activity in ActivityList) { if(activity.Id == GuidToCompare) //Code here } Is there a more efficient way to achieve the same result as I could if I were to have just a list of Guids (instead of a list of Activity's) and to use .Contains()? I've got a list of a struct called ActivityAndPO. In this struct is a Guid. I have a list of PO's. In the PO class is a Guid. I want to loop through all of

Java Hashset.contains() produces mysterious result

落爺英雄遲暮 提交于 2019-11-28 09:49:53
I don't usually code in Java, but recently I started not having a choice. I might have some major misunderstanding of how to properly use HashSet. So it might be possible something I did is just plain wrong. However I'm grateful for any help, you might offer. So the actual problem: In a small program I was writing, I was generating very similar objects, which, when created, would have a very specific id (a string or in my last iteration a long ). Because each object would spawn new objects, I wanted to filter out all those I already created. So I started throwing the id of every new object

How Does List<T>.Contains() Find Matching Items?

Deadly 提交于 2019-11-28 07:05:20
问题 I have a list of car objects List<Car> cars = GetMyListOfCars(); and i want to see if a car is in the list if (cars.Contains(myCar)) { } what does Contains use to figure out if myCar is in the list. Does it do a "ToString()" on my car object. Does it use the Equals() method, the gethashcode()? I see i can pass in my own IEqualityComparer to force my own implementation but just wanted to understand what it does by default. 回答1: Straight from MSDN - List<T>.Contains: This method determines

C# enum contains value

被刻印的时光 ゝ 提交于 2019-11-28 04:27:53
I have an enum enum myEnum2 { ab, st, top, under, below} I would like to write a function to test if a given value is included in myEnum something like that: private bool EnumContainValue(Enum myEnum, string myValue) { return Enum.GetValues(typeof(myEnum)) .ToString().ToUpper().Contains(myValue.ToUpper()); } But it doesn't work because myEnum parameter is not recognized. No need to write your own: // Summary: // Returns an indication whether a constant with a specified value exists in // a specified enumeration. // // Parameters: // enumType: // An enumeration type. // // value: // The value