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

learn more… | top users | synonyms

4
votes
2answers
56 views

Scrabble Tile Counter

Introduction Inspired by this r/dailyprogrammer problem, I've written a Scrabble tile counter. Given a Collection of Scrabble tiles known to be in play, it can ...
1
vote
1answer
61 views

Weightlifting calculator

I'm building a simple iOS app using Swift that calculates the One Rep Max weight a user can theoretically lift. User inputs a weight lifted, the number of repetitions and the app uses one of several ...
2
votes
2answers
82 views

Function to compare objects based on type enums

I'm looking for a better way to implement a huge CompareTo function that relies on an Enum to perform sorting. The data structure is essentially a flattened Multi Level Group. Any ideas and concept to ...
3
votes
1answer
71 views

Enum string parse and get custom attribute assign to array

I wrote a code which: - parse string to my enum - get description from enum - assign to string[] array ...
3
votes
1answer
41 views

Add Field To PDF with Options for Multiple Pages

This is related to here and here. These two methods are used to programatically add a text field to a PDF document. The field can be of any user determined size and have any user determined title, and ...
2
votes
1answer
65 views

Rails validating enum

The Ruby on Rails framework doesn't allow you to validate enums submitted through a form in any sane manner. Evidently, enums are meant to be used to maintain internal application state, and are not ...
7
votes
1answer
106 views

Building a string representing 50+ ActiveDirectory options

I have a switch statement used to handle options that a user selected (stored in an array). The array is iterated through, and for each element (enum object) in the array, an appropriate action is ...
4
votes
0answers
26 views

implementing a StringEnum

this is to be used like an Enum (as parameter mostly), but for string using .net 3.5 Actual Implementation ...
2
votes
2answers
68 views

Enum for converting between field naming conventions

Based on this question and this answer, I decided to try the enum approach to do some more conversions I need in my application. This time I required to convert between the different field naming ...
3
votes
0answers
67 views

Enum to string with template metaprogramming

This allows enum values to be outputted as strings. But enum_strings is a type, not a map or a vector, so if the enum value is known during compile time, there ...
3
votes
2answers
164 views

Operator-based switch for a database query filter

I am currently working on a method, that can search based on a value and an operator. Currently I check which operator was supplied to the the method in a switch, and do operations accordingly to it. ...
8
votes
4answers
2k views

Selecting an enum for a payment transaction

I'm writing a small Android application that deals with payments and, in my function that handles transactions, I need to translate a number of installments (1-12) and whether or not it has interest (...
4
votes
3answers
213 views

Using Enum to Handle String literals

I have a java component that was using a lot of string literals that I need to make comparisons on and return booleans based on these comparisons. In order to make the code more robust I externalized ...
2
votes
1answer
89 views

Poker app in C#

I am developing a poker application using C#. It is almost done, and I'm looking for improvements. One of the things I wonder is whether I should change my method that checks if the player has a flush....
1
vote
1answer
42 views

Single Flag Only Enum (RestrictedEnum<T>)

This class simply allows you to use an enum while only allowing you to set a single flag. If multiple flags are set they will be rejected--unless the total of the combined flags is the same value of ...
2
votes
1answer
56 views

Basic JSON Representation in Rust

This week I started reading "The Rust Programming Language". As I reached the chapters on enumerations and pattern matching I felt I had enough material to put together a simple representation of JSON ...
3
votes
3answers
67 views

Avoiding numbness with Python Enum

First, the context: I'm working with a student to build a web frontend for a star cluster simulation package called starlab. Typical starlab usage involves ...
-2
votes
1answer
80 views

Enum Singleton implementation in Java

I just wanted to implement the enum singleton in java. Here is my implementation where I have tried to create a singleton DataSource instance: ...
6
votes
1answer
52 views

A global Enum for comparison operators

This approach was born out of wanting to pass a logical expression (E.G. ">=10000") as a parameter to a function. So, I built an Enum and a function to use it to evaluate logical expressions. Is ...
7
votes
4answers
979 views

Flags on steroids

What is so bad about [Flags] enum? It does not support IEnumerable<T> anyhow, so to get one we need to use syntax like (...
6
votes
2answers
201 views

Efficiently return a ChatColor

I am working on a plugin for a Minecraft server. In it, I have a function that returns a ChatColor depending on what permission level you are. Whenever I need ...
12
votes
2answers
636 views

Extension method to list enum values

I have the following enum extension method: ...
5
votes
2answers
108 views

Enums for the four directions

I have walls that I can spawn. They wll move in one of four directions, up, down, right or left. Now I can set, wether the wall is thin, wide, long or short, but the problem is: Nearly everything I ...
2
votes
2answers
238 views

Parsing from one enum to another

I face a problem I think I am not approaching appropiately. I have two independent enumerators that both will contain the same members, the only difference being the values given. I have to be able ...
0
votes
1answer
179 views

Remove elements existing in a list built from an enum

The objective of this code is to make the difference inbetween two lists of items, that is knowing which items are missing in the second list in regards to the first one. The first list is built from ...
5
votes
1answer
290 views

Generic method for obtaining enum items in an ushort object

The idea is to perform a bit-wise scan of an ushort provided to find any and all matches within an enum collection. The code I ...
3
votes
2answers
139 views

C++-safe way to use using inside headers

I have this C++ 14 code in a project of mine. Enhedron/Util/Enum.h: ...
8
votes
2answers
1k views

Yet another lightweight Enum for Python 2.7

I'm trying to develop a lightweight enum for Python 2.7. This question is downstream of the SO question here; for context, a streamlined version of the bulleted addendum to that question is ...
8
votes
2answers
208 views

Checking DnD Traits in an enum

Overall, I'm working on a simulator for a modified DnD 3.5 system. Right now, I'm trying to write an enum class that handles the Classes/Professions, and am ...
6
votes
1answer
37 views

Module for isotopic masses and abundances

I have written a small module for accessing data on isotope masses and relative abundances. My long term aim is to build tools in Haskell for working with mass spectrometry data. Any comments on how ...
0
votes
2answers
70 views

Transforming CSS into an encoded representation

I have a java code that is supposed to format the content of a .css file so that I could use the result to make a enum class. ...
7
votes
1answer
334 views

The Yahtzee Game

I am designing two methods to be used in a Java implementation of Yahtzee. For those not familiar with the game: Players take turns rolling dice and acquire points based on the face up values ...
2
votes
0answers
46 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
142 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 ...
4
votes
2answers
125 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
82 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
131 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 ...
8
votes
1answer
480 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
479 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
127 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
100 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: ...
6
votes
1answer
378 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 "user-...
5
votes
0answers
93 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
1k views

EF lookups and enums

I have a lookup table "RequestTypes" that has the following data: ...
4
votes
3answers
53 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 <...
14
votes
2answers
786 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
85 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
93 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
265 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
77 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 ...