The process of enumerating values, for example from some collection.

learn more… | top users | synonyms

255
votes
12answers
207k views

C# loop - break vs. continue

In a C# (feel free to answer for other languages) loop, what's the difference between break and continue as a means to leave the structure of the loop, and go to the next iteration? Example: ...
51
votes
4answers
36k views

What does the “map” method do in Ruby?

I'm new to programming. Can someone explain what .map would do in: params = (0...param_count).map
-1
votes
2answers
66 views

Issue with assigning enum value

I have an enum - public enum EnumA { All, A, B, C, D, E, F } I am using this enum into another class public class ClassB { public string[] createdOn { get; set; } public EnumA[] ...
2
votes
1answer
133 views

brainspec/enumerize throwing mysql error for default value

I'm working on a Rails 4 app, and I've begun using brainspec/enumerize gem. I have an integer value in the database, column status and would like to enumerate it in my model. Below you can see the ...
3
votes
7answers
95 views

Determine if an Enum value is NOT a composite in C#

EDIT: Most people suggest that flag enums should always have values of powers of two. That may be best practice but I am not defining enums here, rather checking them and want to cover all possible ...
0
votes
1answer
32 views

Determine underlying integral type of an Enum in C# [duplicate]

Consider the following enumerations: enum TestSByte: sbyte { Value1, Value2, } enum TestInt16: short { Value1, Value2, } enum TestInt32: int { Value1, Value2, } enum TestInt64: long { ...
0
votes
0answers
16 views

Enumerable select to set attribute and return object

I need to iterate over an array, set an attribute, and return the modified objects. Obviously, map can be used like so: items.map do |item| item.foo = bar item end But it seems bulky for ...
5
votes
6answers
95 views

Await list of async predicates, but drop out on first false

Imagine the following class: public class Checker { public async Task<bool> Check() { ... } } Now, imagine a list of instances of this class: IEnumerable<Checker> checkers = ... ...
94
votes
8answers
28k views

Case classes vs Enumerations in Scala

Are there any best-practice guidelines on when to use case classes vs extending Enumeration in Scala? They seem to offer some of the same benefits.
22
votes
9answers
5k views

Why cant we change Values of a dictionary while enumerating its keys?

class Program { static void Main(string[] args) { var dictionary = new Dictionary<string, int>() { {"1", 1}, {"2", 2}, {"3", 3} ...
-3
votes
3answers
40 views

Define Enumeration inside Main() gives compile Error ( c#)

Define Enumertion inside Main() gives compile error,Why it so ? (If define it in 'class program, working fine) using System; class program { // If define here, it ...
-2
votes
1answer
41 views

Exit recursive function

I Loop through a complex JSON object but I want to stop the loop after n iterations n = 0; maxIterations = 100; ObjectValues = function(v, k){ if(n == maxIterations){ if (typeof v == "object") ...
1
vote
1answer
24 views

BAR regions unallocated after PCIe rescan on Linux

I have an FPGA card attached to PCIe on a Linux system. I can re-program the FPGA and then echo 1 > /sys/bus/pci/rescan and my card shows up in lspci. However the BAR regions aren't allocated any ...
-1
votes
1answer
28 views

How to enumerate registered COM servers

Is there any "high level" method to enumerate the registered COM servers in C#? I would like to avoid direct registry access and also prefer to get some sort of list of "objects" containing at ...
0
votes
0answers
10 views

In XSD how to I define a simple type enumeration with an attribute

I want to define the following element in XSD using a seperate type (so that I can use it several times): <qcStatus action="update">passed</audioType> Where "update" is an enumeration ...
1
vote
1answer
56 views

Haskell: Having each enum element associated with a unique Vector value

I thought about making a Direction data type and I'd like to have each element associated with a 3d Vector indicating the x, y and z value of the direction. Up, for instance, would have the value 0 1 ...
1
vote
1answer
260 views

How to get the name of enumeration value in Swift?

If I have an enumeration with raw Integer values: enum City: Int { case Melbourne = 1, Chelyabinsk, Bursa } let city = City.Melbourne How can I convert a city value to a string Melbourne? Is ...
0
votes
1answer
33 views

Entity Framework 6 Code First - Required Enum data type not working

I am generating a database table using an required enum field. However, when feeding the table, it is possible to omit to feed the enum field: EF will not throw any error message but will feed the ...
-1
votes
2answers
53 views

enumerating numbers in strings

This seems like a problem that would have a fairly straight-forward answer; sadly, I am not that fluent in Python as I'm still learning, and I have not been able to find anything helpful on Google. ...
0
votes
1answer
25 views

Enumeration is empty when i am trying to populate it with com port list

I have a device connected at my com port and I am trying to get its values but I am stuck at the first step. I am unable to get the existing com ports. In the code below by enumeration seems to be ...
38
votes
10answers
15k views

Which Typesafe Enum in C++ Are You Using?

It is common knowledge that built-in enums in C++ are not typesafe. I was wondering which classes implementing typesafe enums are used out there... I myself use the following "bicycle", but it is ...
0
votes
1answer
226 views

How to use “enumerateChildNodesWithName” with Swift in SpriteKit?

I'm using Swift to make a game in SpriteKit. In Objective-C I could use the following method: (void)enumerateChildNodesWithName:(NSString *)name usingBlock:(void (^)(SKNode *node, BOOL *stop))block ...
0
votes
1answer
49 views

Having users reference nodes of a tree structure

I am writing an app which stores hierarchical data in a tree structure of python class instances. The root node will have a list of children and each child will also have their own children in a ...
0
votes
1answer
22 views

How does base address register gets address?

I've finished developing a pcie driver for an FPGA under a linux distributiuon. Everything works fine. But I'm wondering where the base address register in the PCI Endpoint of the FPGA gets the base ...
3
votes
3answers
85 views

How to stop enumerateObjectsUsingBlock Swift

How do I stop a block enumeration? myArray.enumerateObjectsUsingBlock( { object, index, stop in //how do I stop the enumeration in here?? }) I know in obj-c you do this: ...
1
vote
1answer
18 views

Why NSEnumerationReverse and not NSEnumerationForward

I was looking at looping through an array and I stumbled across this method -- - (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(id obj, ...
4
votes
2answers
67 views

Class or enumeration using declaration

The beginning of 3.4.3.1/1 of N3797 said: If the nested-name-specifier of a qualified-id nominates a class, the name specified after the nested-name-specifier is looked up in the scope of the ...
0
votes
1answer
84 views

Can associated values and raw values coexist in Swift enumeration?

There are examples on Swift book demonstrating associated values and raw values separately, is there a way to define enumeration with the two features together. I have tried to combine them, but got ...
-3
votes
1answer
32 views

Read third enum constructor value by passing initial 2 values

I have below enum public enum MyTest{ READIT("1", "2", "3"); } In my class I have "1" & "2" coming dynamically, however the name given to enum i.e. READIT is unknown to my class, passing ...
3
votes
1answer
85 views

How to get correct value type when extending Scala Enumeration.Val

While there are many questions on S/O regarding difficulties with Scala Enumeration, I haven't found a question that addresses my problem. Specifically, I am trying to translate the Planet example ...
0
votes
1answer
52 views

Using Enumerations as type parameters

I want to write a method like this: def validate[T <: Enumeration](input: String)(implicit enum: T) : Seq[T] that will take an input ("foo,bar,baz") and split it with commas - then compare to the ...
0
votes
2answers
21 views

Possibility of mapping enum values to string type instead of integer

Enum attributes are great and I want to use them. But mapping enum values to integer would make it hard to maintain both code and database. Also my database would be highly coupled with my code which ...
0
votes
1answer
53 views

Spring Autowire XML: value is not facet-valid with respect to enumeration

I am trying to run a code for Spring Auto wiring. I am using "autodetect" as autowire attribute value for bean configuration. I am getting below error. INFO: Loading XML bean definitions from class ...
3
votes
6answers
1k views

Python: Fastest way to find a string in an enumeration

Parsed the IANA subtag (see Cascaded string split, pythonic way) and made a list of 8600 tags: tags= ['aa', 'ab', 'ae', 'af', 'ak', 'am', 'an', ...
-1
votes
2answers
41 views

Prevent collection from being modified while enumerating

how do i prevent Collection from being modified during Enumeration. Here is the class source code. public class cars : IEnumerator,IEnumerable { private car[] carlist; int position = -1; ...
3
votes
1answer
54 views

Differences between [1,2,3].to_enum and [1,2,3].enum_for in Ruby

In Ruby I'm trying to understand between the to_enum and enum_for methods. Before I my question, I've provided some sample code and two examples to help w/ context. Sample code: # replicates ...
4
votes
2answers
3k views

Resharper warning on *all* uses of an enumerable about “Possible Multiple Enumeration”

I'm getting the "Possible Multiple Enumeration of IEnumerable" warning from Reshaper. How to handle it is already asked in another SO question. My question is slightly more specific though, about the ...
6
votes
3answers
10k views

Strange “Collection was modified after the enumerator was instantiated” exception

Perhaps someone can point me in the correct direction, because I'm completely stumped on this. I have a function that simply prints out a LinkedList of classes: LinkedList<Component> ...
2
votes
2answers
45 views

Specify starting point of foreach enumerator in ruby

I have a rake file that pulls in data from an external CSV file and enumerates through it with: CSV.foreach(file, :headers => true) do |row| What is the most effective way (in ruby) to specify ...
0
votes
1answer
41 views

Why does mapping over a Scala enumeration's ValueSet not change the type of the values?

I found some puzzling behavior in Scala's ValueSet. With an enum like this, object MyEnum extends Enumeration{ val V1 = new MyEnum val V2 = new MyEnum class MyEnum extends Val ...
1
vote
1answer
35 views

XSLT: Get enumeration from xsd

I've this enum in the xsd file: <xs:simpleType name="SO"> <xs:restriction base="xs:string"> <xs:enumeration value="Mac OS X"/> <xs:enumeration ...
0
votes
0answers
6 views

Why does keys() of java.util.concurrent.ConcurrentHashMap returns an enumeration instead of iterator

I noticed that "Iterator takes the place of Enumeration in the Java collections framework." (From the Iterator specifications.). Why does keys() and elements() of ...
0
votes
1answer
29 views

How do I stop an NSSet from being mutated while it's being enumerated elsewhere?

I have an NSMutableSet of objects which I mutate at several points on the main thread. There are times though when this set will be enumerated on a background thread. Short of using a bunch of ...
479
votes
23answers
161k views

PHP and Enumerations

I know that PHP doesn't have native Enumerations. But I have become accustomed to them from the Java world. I would love to use enums as a way to give predefined values which IDEs' auto completion ...
1
vote
1answer
126 views

Z3 Enumerating all satisfying assignments

I am trying to solve a problem similar to the one here (Z3: finding all satisfying models) where I need to find all satisfying assignments of SMT formulae that contain set variables. I understand the ...
1
vote
2answers
33 views

foreach loop item removal from an enumerated collection

I can't figure out why this works: var list = new List<int>() { 1, 4, 3, 2, 0, 1 }; foreach (var item in list.ToList()) { if (item == 1) { list.Remove(item); } } ...and ...
0
votes
1answer
21 views

how to link radiobuttons with enumeration?

im making a webshop to assemble your PC and i have radiobuttons for each part of the computer. example: <Form name ="formprocessor" Method ="Post" ACTION ="radioButton.php"> <Input ...
1
vote
1answer
31 views

exc_bad_access when enumerating and adding object to NSMutableSet

I keep getting the following exception from time to time when objects are added to a NSMutableSet: Thread 6: EXC_BAD_ACCESS (code=1, address=0x0) It occurs in the following block of code: - (NSSet ...
2
votes
1answer
20 views

Accessing (/importing) Scala Enumerations

For the following HwLogger.PersisterType enumeration: object HwLogger extends Serializable { object PersisterType extends Enumeration { type Persisters = Value val FilePersister, ...
4
votes
1answer
159 views

Different behaviour between enumerateObjectsUsingBlock: and for( in )

Give this code NSMutableArray *array = [NSMutableArray new]; for (int i = 0; i < 10000; i++) { [array addObject:@(i)]; } queue1 = dispatch_queue_create("com.test_enumaration.1", ...