A data type consisting of a set of named values called elements, members or enumerators of the type.

learn more… | top users | synonyms

2
votes
0answers
27 views

“EnumSpace” - enum inheritance attempt using namespace macro

EnumSpace This file enables the use of a utility I like to call "EnumSpace". This utility is enums and ...
1
vote
1answer
44 views

Bitmask type to perform binary operations

Without any specific implementation details, how would you create a bitmask type that wraps binary arithmetic into something easy to read? Ideally, this would be used with an ...
3
votes
2answers
103 views

Handling Enum flags for a copy operation

I've just set up a bit of code to try and make things neater, but all I've really done, is add a whole bunch of nested if statements: ...
5
votes
1answer
72 views

Enumerations for a game character's statistics

I would like to improve my functions and work properly on enums without all of those IFs as well as make it more consistent (for example ...
7
votes
2answers
101 views

Efficiently checking if a large enumeration has a consistent order

The scenario is as follows: We have a streamed enumeration that we have to check if it's ordered or not before processing it (about 75-80% of the time it is ordered). We are talking about pretty big ...
7
votes
0answers
75 views

Attempt at type-safe enums in JavaScript

I wrote this tiny library yesterday. The goal was to implement enums in JavaScript with type-safety. I modeled the implementation similar to enums in Java, since that is what I am most familiar with. ...
5
votes
2answers
269 views

Function to toggle between two values of an enum

I have this code, but it looks a bit verbose: enum MonitoringMode { Seek, Destroy } ...
4
votes
1answer
116 views

Class for modifying stats of units

I am specifically looking for input on naming ModifierCalculator and Modifiers. I would also appreciate input on whether ...
2
votes
1answer
50 views

Sort files by the type of file

I need to sort files by the type of the File. To accomplish the task I first wrote the code below: ...
5
votes
1answer
92 views

C++ FlagSet: typesafe usage of enumeration as bitset/bitmask

Below is my attempt at providing a type-safe way to combine enumeration and bitset together. The resulting class is intended to be use as a set of flags, where each flag is a member of the ...
5
votes
0answers
48 views

Suggesting “safe enum” class for ISO C

There are quite some questions and answers about how to make enum really type-safe and I didn't find a solution that ensures both type safety and valid values. So I ...
6
votes
2answers
270 views

EF lookups and enums

I have a lookup table "RequestTypes" that has the following data: ...
4
votes
3answers
51 views

Page Enum with overridden methods for the first and last members

I am managing the changing of views in an Android app using this enum and associated methods. I am particularly interested in the Page enum's use of overriding ...
13
votes
2answers
389 views

Localizing an enum in Java

I am currently using an enum in my Android application to display time periods: Weekly Bi-Weekly Monthly Quarterly Yearly I created the enum like this, because I wanted to know the description, ...
2
votes
1answer
83 views

Populate the list based on which datacenter code is running on

This is a follow on to : Efficiently detect datacenter based on server hostname and return the full path. I have a library which is running in different datacenters in production. I have three ...
5
votes
1answer
82 views

Efficiently detect datacenter based on server hostname and return the full path

I have a library which is running in different datacenters in production. I have three datacenters in production: DHP, SLP, LTR Depending on which datacenter ...
6
votes
3answers
215 views

Enum Constants for Convert Units

I have a few constants in a game that I'm doing for hobby. I need to store constants for the total size of the a Physical World and the size of the Screen. I can position the world's objects to the ...
3
votes
3answers
74 views

Device-dependent image descriptor fields

In a Java class that belongs in a library, I have a field size that indicates size of image. It must be int, but some values are ...
1
vote
1answer
91 views

Implementing a date validator using enum

First and second post on the same subject. This is such a great way to learn. Once again I'm open to suggestions. I have implemented almost all of the suggestions from before, which have resulted in ...
9
votes
4answers
283 views

Enumerated rank comparator utility class

A common task I often face is ordering a collection of items according to some predefined model, typically expressed as an ordered list of ranks. For example, credit agencies might rate financial ...
3
votes
1answer
131 views

Enums for measurement units, with possible circular dependency

I have some enums that define measurement information, such as volume, mass, distance etc... They are defined as such: ...
3
votes
2answers
144 views

Map enum values

I want to map values of a enum to some other values. For instance, here I map Color to Group: ...
0
votes
3answers
98 views

Mixing business logic and presentation layer in enum type

Let's assume I have an enum type with currency: ...
6
votes
0answers
94 views

Possible class redundancy and improper enum usage

I am looking for code correctness and design usage as I think I might be over doing it in the class department. There are two things I'm mostly concerned with. The possible redundancy of classes ...
7
votes
3answers
586 views

Using enum descriptions to string/text binding

In my WP8 application I need to show a couple of radio buttons to let the user select a value out of an enum. I don't want to hardcode either the value or the text ...
3
votes
2answers
218 views

Mapping enum keys to instance values

I am working on a pathfinding program / algorithm, and I have the following class: ...
2
votes
2answers
99 views

Extracting name and value from the enum

I wrote the below enum from which I need to extract the name and its value: ...
17
votes
2answers
662 views

Enum, constants, or other to represent chess pieces

I'm learning C# and I decided to write a chess program to help me practice the concepts I'm learning in my book. I started the Board class tonight, which is going to handle 1) the board state and 2) ...
13
votes
1answer
964 views

Let's play some Swift Poker

Before you can do any sort of card game, you must first write some code to define your deck of cards. One thing I've noticed in looking at some of Apple's Swift interfaces is that they very much so ...
1
vote
0answers
82 views

Enum list to STL container, part 2

Original question: Enum list to STL container Goal: Write a function enumToSTLContainer() that is to return any STL container whose elements are from a specified ...
2
votes
1answer
120 views

Enum list to STL container

Can someone improve upon this function of mine? EnumToSTLContainer is supposed to make a copy of any STL container whose elements are from a specified ...
6
votes
1answer
134 views

Supporting Enum in EF 5 with .Net 4.0

I'm currently working through Getting Started with EF5 using MVC 4 in Visual Studio 2010 (.NET 4.0) to learn about how to use ASP.NET and Entity Framework. During the beginning of the tutorial I ran ...
9
votes
1answer
525 views

Too much fun with EnumMap-related features and lambdas?

I have created an utilities class to handle certain EnumMap-related features, such as creating and converting between ...
6
votes
3answers
440 views

Leaving out the max value in an Enumeration

This is part of a school assignment and I came up with the following solution to leave out the max value in a Enumeration: ...
5
votes
1answer
59 views

Reading OS X file tags

I'm investigating Go for use in our internal network / office project management system, and need a way to check and edit the color tags that you can set in Finder on files or folders (extended ...
14
votes
2answers
434 views

Vector-to-direction method in Java

I don't really have a problem, but my code bothers me, because I know it could be done in a much better way. I have an enum of 4 directions: north west, north ...
6
votes
1answer
3k views

Iterable enum class in C++11

For a small project I'm working on, I've been looking for an iterable enum-like class in C++, since neither C-style nor scoped ...
8
votes
3answers
483 views

Java enum for mapping classes and specific URL

I have a ZK project in Java 6 (ZK is like ASP.NET but with zul files in stead of aspx). For showing and creating/updating the ...
5
votes
3answers
286 views

Is this good design for custom email template?

I read effective Java by Joshua Bloch. And it said use enums over int constant. So I was thinking instead of using hard coded strings I could also use enums. The forgotpassword.txt and ...
7
votes
2answers
105 views

Validating multiple keys in the builder class based on the rules

I recently started using Builder pattern in one of my projects and I am trying to add some sort of validations on my Builder class. I have already asked a question, got some feedback and incorporated ...
1
vote
1answer
80 views

Making a URL by prioritizing the keys if multiple keys are present efficiently

I recently started using the Builder pattern in one of my projects. Below is my builder class - ...
6
votes
2answers
80 views

Efficiently returning the string basis on current datacenter

We have machine hostname as - dbx111.dc1.host.com dbx112.dc2.host.com dcx113.dc3.host.com dcx115.dev.host.com Here dc1, ...
8
votes
4answers
665 views

An enum that has situationally invalid entries

Is it considered bad style to have that BOTH value in the Direction enum? Problems can arise from ...
3
votes
1answer
85 views

An attempt to extend an enum to prevent branching without violating the Open-Closed principle

I love making utility State enums, and giving them methods that do useful things based on which instance of the enum is provided. This works when the enum is very specific to the class I'm working on, ...
6
votes
1answer
3k views

Smart enum templates

Here is some code I wrote 10 years ago. I'm now reviewing it and there are a lot of things I don't like. There is possibility for weird behaviour if the template is attempted to be used with a type ...
14
votes
4answers
1k views

Enum with getting subset

I just wrote this but I'm not sure if this is good practice. Can someone give me advice as to whether it's good or how I can do better or even it's bad code? The point is that I need a sub ...
4
votes
1answer
254 views

“Agenda” test application for Enum

I'm still new in Java so I always try to find new ways and improve my skills. I found enum in Java to be very powerful (maybe excessively?) and while I was reading ...
15
votes
5answers
9k views

Java enum containing a hash map for look up

I have the below enum. I need to get the description by code. It is working but can it be improved still? ...
7
votes
4answers
1k views

Saving enum value using name()

Let's assume I have an enum type enum ComponentState { TURNED_OFF, TURNED_ON, SUSPENDED, TO_REPAIR; } This enum describes a state of some ...
5
votes
1answer
128 views

Enumerating a boolean in C

This is one way to make a boolean in C. typedef enum { false = 1 == 0, true = 0 == 0 } bool; Recently I made some like ...