enumeration Questions

5

Solved

Lets's say I have an enumerator, is it possible to get the property that follows? So if I had today=Days.Sunday would I be able to do something like tomorrow=today.next()? example: class Days(Enu...
Ideation asked 26/10, 2014 at 20:32

2

I'm trying to add new elements to a list of lists while iterating over it List<List<String>> sets = new List<List<string>>(); foreach (List<String> list in sets) { ...
Spital asked 24/5, 2017 at 3:9

10

I want to enumerate through an array in Swift, and remove certain items. I'm wondering if this is safe to do, and if not, how I'm supposed to achieve this. Currently, I'd be doing this: for (inde...
Paddlefish asked 4/2, 2015 at 14:28

13

Solved

I'm looking to see if there is an official enumeration for months in the .net framework. It seems possible to me that there is one, because of how common the use of month is, and because there are...
Inveracity asked 22/5, 2009 at 19:21

36

Solved

How can you enumerate an enum in C#? E.g. the following code does not compile: public enum Suit { Spades, Hearts, Clubs, Diamonds } public void EnumerateAllSuitsDemoMethod() { foreach (Suit...
Illconditioned asked 19/9, 2008 at 20:34

40

Solved

I know that PHP doesn't yet 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-complet...
Copyread asked 31/10, 2008 at 18:51

20

Solved

Is there a function that I can use to iterate over an array and have both index and element, like Python's enumerate? for index, element in enumerate(list): ...
Giordano asked 4/6, 2014 at 3:19

6

Solved

In Python 3, I want to limit the permitted values that are passed to this method: my_request(protocol_type, url) Using type hinting I can write: my_request(protocol_type: str, url: str) so the pr...
Virgel asked 22/4, 2019 at 9:30

3

Solved

I have a vector V of consecutive integers of length l , e.g., 1, 2, 3, 4, 5, 6, 7. I want to find all subsets of size k such that the difference between any two numbers in the subset can be no less...
Diva asked 24/8, 2023 at 20:46

3

Solved

So I have a Dictionary<string, bool> and all I want to do is iterate over it and set all values to false in the dictionary. What is the easiest way to do that? I tried this: foreach (string...
Bonfire asked 27/5, 2011 at 4:20

4

Solved

I have a distributed system defined by a sort of "state machine" ( "flow chart" ) each system writes there state in a shared "log" I'm representing each state as part of a sealed trait and a give...
Sledge asked 3/9, 2019 at 14:48

1

If I connect a USB device to the host and then upgraded the USB device with a new firmware with changes in the Descriptor of the device. The host will use the old descriptor. I know that I can for...
Abrahamabrahams asked 23/10, 2018 at 10:30

7

Solved

Considering such an enumeration : type TTypeOfData = ( [XmlName('ABC')] todABC, [XmlName('DEF')] todDEF, [XmlName('GHI')] todGHI ); Where XmlName is a custom attribute used to define the s...
Bergstein asked 25/1, 2010 at 17:19

12

Solved

In Java you could: public enum Enum { ONE { public String method() { return "1"; } }, TWO { public String method() { return "2"; } }, THREE { public String method() { return "3"; } ...
Toxinantitoxin asked 3/12, 2010 at 14:38

11

Solved

How can I cast a value from Enum1 to Enum 2 in Java? Here is an example of what I'm trying to do : public enum Enum1 { ONE, TWO, THREE; } public enum Enum2 { FOUR, FIVE, SIX; } So I want ...
Exodus asked 2/9, 2011 at 13:54

5

Solved

I'm trying to make a helper method for listing the names of all bits set in an Enum value (for logging purposes). I want have a method that would return the list of all the Enum values set in some ...
Allanite asked 11/4, 2012 at 18:48

10

Solved

What is the exact use of AsEnumerable? Will it change non-enumerable collection to enumerable collection?.Please give me a simple example.
Sivan asked 19/11, 2009 at 15:1

3

Solved

I'm writing a Python script that receives protobufs, converts them to json objects, and pushes them to another service. I use json.loads(MessageToJson(protobuf)) to convert the protobuf to a python...
Feld asked 23/3, 2017 at 21:23

11

I have the classic case of trying to remove an item from a collection while enumerating it in a loop: List<int> myIntCollection = new List<int>(); myIntCollection.Add(42); myIntCollect...
Darindaring asked 25/8, 2011 at 15:43

3

Solved

In one place i am using the list of string in that case the i am able to change the value of the string as code given below, foreach(string item in itemlist.ToList()) { item = someValue; //I am ab...
Sinfonia asked 16/7, 2013 at 12:50

7

How can I get the name of a Java Enum type given its value? I have the following code which works for a particular Enum type, can I make it more generic? public enum Category { APPLE("3"), OR...
Tamartamara asked 8/10, 2010 at 9:23

5

Solved

For example, Math.mymfunc = function (x) { return x+1; } will be treated as a property and when I write for(var p in Math.__proto__) console.log(p) it will be shown. But the rest of Math fu...
Oxus asked 25/9, 2011 at 20:13

6

Solved

In Java 5 and above you have the foreach loop, which works magically on anything that implements Iterable: for (Object o : list) { doStuff(o); } However, Enumerable still does not implement Ite...
Esposito asked 26/8, 2008 at 1:57

3

Solved

Is there a way to enumerate the items in a list within mockito's thenReturn function so I return each item in a list. So far I've done this: List<Foo> returns = new ArrayList<Foo>(); /...
Vair asked 23/10, 2015 at 20:33

7

Solved

I just start to learn programming and I am trying to work out the experiment in Swift programming book. It asks "“Write a function that compares two Rank values by comparing their raw values.” e...
Avelin asked 2/7, 2014 at 16:59

© 2022 - 2025 — McMap. All rights reserved.