enumeration

node.js: Enumerating socket clients...

Hi, I'm trying to create a server app in node.js, where multiple clients connect, and then one sends data, and that data gets send to another specific client. Which client it gets sent to is determined by a 'user id' that all clients will send after they connect. How can I keep track of clients as they connect? How can I find my specif...

Java Enums - Number add() and classification method

hi, I am creating an api for a phonebook which has 3 different types of phone-numbers:FAX, HOME, WORK, CELL I want to add a number to a specific type but do not want to classify FAX,HOME,WORK etc. as primitive types as I am considering that I could change it at a later date. I was trying to use enums but am not clear how I can use it ...

Enums in Java API

hi, I am creating a java API for an addressbook Is it a good practice to use Enums in my API ? I am using it as follows: public enum AddressType { WORK,HOME } public class AddressBook implements Function{ Map<String, Details> byName = new TreeMap<String,Details>(); public void addNewContact(String name, String address, A...

Force Initialization of an enumerated type in Java

I am attempting to find a way to force Java to load/initialize an enumerated type (which is nested within a class that contains a static Map). This is important to me because the enumerated type has a constructor that populates said map, and without an explicit way to initialize this enum, the map will remain empty. I have attempted to...

C# batching enumerator

Possible Duplicate: LINQ Partition List into Lists of 8 members. I've got an IEnumerable<T> and I'd like to transform it into an IEnumerable<List<T>> where each List is a batch of items in the same order as the original enumerator. Each batch should be batchSize items in length, except for the last batch which should contain l...

Java getting the Enum name given the Enum Value.

Hi, How do I get the name of a Java Enum type given its value? I have written code which works for a particular Enum type, can I make it more generic? The enum type: public enum Category { APPLE("3"), ORANGE("1"), GRAPE("GRAPE"), BANANA("Banana"); private final String identifier; /** * Constructor. * * @p...

Collection was mutated while being enumerated crash with NSTableView, NSArrayController and NSThread

Hi! In my small Core Data application I have some NSTableView views binded with NSArrayController controllers in Entity mode. When I try to import some big amount of data to my table in background thread, after some successfully added imports (from dozens to hundreds items) I get crash with log: Serious application error. Exception w...

Enumerating NOAA weather conditions?

I am trying to use the NOAA API for current weather conditions observations and don't know if there is an enumerated list of all the possible weather conditions that they can generate. As an example if I use Yahoo's API (using a woeid near Apples Headquarters as an example) with the URl: http://weather.yahooapis.com/forecastrss?w=12797...

Loop through values or registry key.. _winreg Python

How would I loop through all the values of a Windows Registry Key using the Python module _winreg. I have code that will do what I want, but it is for the subkeys of the specified registry key. Here Is The Code: from _winreg import * t = OpenKey(HKEY_CURRENT_USER, r"PATH TO KEY", 0, KEY_ALL_ACCESS) try: i = 0 while True: ...

JSTL foreach on enum

I have a contant list declared in java using enum type, that must appears in a jsp. Java enum declaration : public class ConstanteADMD { public enum LIST_TYPE_AFFICHAGE { QSDF("qsmldfkj"), POUR("azeproui"); private final String name; @Override public String toString() { return name; ...

"if" statement vs OO Design

I have enum say ErrorCodes that public enum ErrorCodes { INVALID_LOGIN(100), INVALID_PASSWORD(101), SESSION_EXPIRED(102) ...; private int errorCode; private ErrorCodes(int error){ this.errorCode = error; } //setter and getter and other codes } now I check my exception error...

Java enum in practice, bad code to improve

I want to improve my use of JDK 1.5 and stop using private static final String instead of enum. This is what seems to be recommended. But now my constant class looks like this : public class CEnum{ /** * @author JJA * date : 20/10/2010 */ public enum ListTypeAffichage { DEP("DEPOT_TVA"), PAD("PAS_DEPOT_T...

Random enumeration of a hash table in OCaml

Hi, Sorry for the long question. I decided to explain the context of the problem first as maybe there are other solutions to my problem. If you're in a hurry, just read THE QUESTION below. (EDITED -- In the mean time I added some attempts to solve the problem. The fourth one has my final conclusion, you can jump straight to it.) THE C...