In computer programming, an enumerated type is an abstract data type used to model an attribute that has a specific number of options (or identifiers) such as the suit of a playing card (i.e. a Club, Diamond, Heart or Spade). Using this type allows the program to handle the attribute more efficiently than a string while maintaining the readability of the source code.

PropertyValue
p:abstract
  • In computer programming, an enumerated type is an abstract data type used to model an attribute that has a specific number of options (or identifiers) such as the suit of a playing card (i.e. a Club, Diamond, Heart or Spade). Using this type allows the program to handle the attribute more efficiently than a string while maintaining the readability of the source code. At run-time, enumerated types are often implemented using integers (each identifier has a distinct integer value). However, compared to using just integers, enumerated types make program source more self-documenting than the use of explicit magic numbers. Depending on the language, the integer representation may not be visible to the programmer; this prevents the programmer from doing absurd things, like performing arithmetic on enumeration values. In some languages, the boolean type of truth values is considered a predeclared enumerated type of two values. More about enums: The enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type, which can be any integral type except char. The default underlying type of the enumeration elements is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1. For example: enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri}; In this enumeration, the sequence of elements is forced to start from 1 instead of 0. A variable of type Days can be assigned any value in the range of the underlying type; the values are not limited to the named constants. The default value of an enum E is the value produced by the expression (E)0. enum Days {Sat, Sun, Mon, Tue, Wed, Thu, Fri}; In this enumeration, Sat is 0, Sun is 1, Mon is 2, and so forth. Enumerators can have initializers to override the default values. For example: (en)
  • Ein Aufzählungstyp (englisch enumerated type) ist ein Datentyp mit einem endlichen Wertebereich. Alle Werte des Aufzählungstyps werden bei der Deklaration des Typs mit Namen definiert. Dabei wird auch eine Reihenfolge festgelegt, die eine Ordnung der einzelnen Werte bestimmt, die Werte können also sortiert werden. Aufzählungstypen sind z. B. in den Programmiersprachen Pascal, Modula-2, Modula-3, Ada, Haskell, C und C++ ein übliches Mittel. In Java werden Aufzählungen erst seit der Version 5 unterstützt, dafür sind sie hier als echte Objekte mit objektorientierten Mitteln flexibel erweiterbar. Man unterscheidet typenlose Aufzählungen wie in C, die lediglich Namen für numerische Werte festlegen, und typsichere Aufzählungen wie in Pascal und Java. Typsichere Aufzählungstypen verhindern, dass „Äpfel mit Birnen“ verglichen werden. So wäre beispielsweise die Farbe BLAU aus dem unten stehenden Beispiel ein anderer Wert als das erste Element eines anderen Aufzählungstypen (z. B. Obst). Einer Variablen vom Typ Farbe könnte niemals ein Wert vom Typ Obst zugewiesen werden. Dies bringt den Vorteil, dass der Compiler automatisch fehlerhafte Zuweisungen verhindern kann. Ein Beispiel für einen Aufzählungstyp in Java, der Farben repräsentiert: enum Farbe {BLAU, GRUEN, ROT, GELB} Ein Beispiel für einen Aufzählungstyp in Java, der Obst repräsentiert: enum Obst {APFEL, KIRSCHE, PFLAUME} Dies ermöglicht die folgende Zuweisung, in welcher der Variable tapetenfarbe vom Typ Farbe der Wert BLAU zugewiesen wird: Farbe tapetenfarbe = BLAU; In einer typensicheren Programmiersprache würde folgendes einen Fehler erzeugen: Farbe tapetenfarbe = APFEL; //FEHLER! (de)
  • 列挙型(れっきょがた、)とは、コンピュータプログラミングにおいて、プログラマが選んだ各々の識別子をそのまま有限のセットとして持つ抽象データ型である。列挙型は一般に番号順を持たないカテゴリ変数(カードの組のように)として使われる。実行時には、列挙型は整数で実装されることが多い(各々の識別子は異なる整数値を持つ)。 また列挙型は、整数を使用する場合と比較して、明示的にマジックナンバーを使用するよりもプログラムソースの可読性を改善するのに役立つ。言語によっては、列挙型の整数表現はプログラマに見えないようになっていることもあり、これによりプログラマが列挙値に対して算術演算を行うような乱用を防いでいる。 言語によっては、真偽値の論理型は、あらかじめ宣言された二値の列挙型とされている。 (ja)
  • Een enumeratie of opsomming is een datatype in verschillende programmeertalen. Variabelen van een enumeratietype kunnen een vaststaand aantal waarden aannemen, die met een identifier kunnen worden aangeduid. Bijvoorbeeld (in C): typedef enum { rood, oranje, geel, groen, blauw, paars } kleur_t; kleur_t kleur = rood; Bijvoorbeeld (in Pascal): type Tenum = { rood, oranje, geel, groen, blauw, paars } ; var kleur_t : Tenum begin kleur_t := rood; end ; Over het algemeen worden de waarden van een enumeratietype intern weergegeven door een (kleine) integer. In C kunnen enumeratiewaarden en integers makkelijk naar elkaar geconverteerd worden, en zijn de waarden uit het voorbeeld hierboven equivalent aan de integers 0 tot en met 5. (nl)
  • Typ wyliczeniowy - w językach programowania rodzaj typu danych zawierający listę wartości, jakie może przyjmować zmienna tego typu. Typ wyliczeniowy pełni nieocenioną funkcję w Metaprogramowaniu, gdyż pozwala na tworzenie stałych w chwili kompilacji. (pl)
  • em programação, uma enumeração é um tipo de dado abstrato, cujos valores são atribuídos a exatamente um elemento de um conjunto finito de identificadores escolhidos pelo programador. Esse tipo é geralmente usado para variáveis categóricas (como os naipes de um baralho), que não possui uma ordem numérica definida. Em tempo de execução, um tipo de dado enumerado é geralmente implementado usado-se inteiros. Entretanto, comparando-se a usar somente inteiros, os tipos enumerados tornam o código fonte mais bem documentado que através do uso explícito de "números mágicos". Dependendo da linguagem, a representação de inteiro pode não ser visível ao programador, o que previne operações como aritmética de enumerações. Em algumas linguagens, o tipo booleano é declarado como uma enumeração de dois valores, verdadeiro e falso. (pt)
  • Перечисляемый тип (сокращённо перечисле́ние, ) — в программировании тип данных, чьё множество значений представляет собой ограниченный список идентификаторов. (ru)
p:hasPhotoCollection
p:javadocSeProperty
  • Enum (en)
  • EnumMap (en)
  • EnumSet (en)
  • java/lang (en)
  • java/util (en)
p:name
  • ordinal() (en)
p:reference
p:wikiPageUsesTemplate
p:wikibooksparProperty
  • Ada_Programming (en)
  • Types/Enumeration (en)
p:wikipage-de
p:wikipage-ja
p:wikipage-nl
p:wikipage-pl
p:wikipage-pt
p:wikipage-ru
rdf:type
rdfs:comment
  • In computer programming, an enumerated type is an abstract data type used to model an attribute that has a specific number of options (or identifiers) such as the suit of a playing card (i.e. a Club, Diamond, Heart or Spade). Using this type allows the program to handle the attribute more efficiently than a string while maintaining the readability of the source code. (en)
  • Ein Aufzählungstyp (englisch enumerated type) ist ein Datentyp mit einem endlichen Wertebereich. Alle Werte des Aufzählungstyps werden bei der Deklaration des Typs mit Namen definiert. Dabei wird auch eine Reihenfolge festgelegt, die eine Ordnung der einzelnen Werte bestimmt, die Werte können also sortiert werden. (de)
  • 列挙型(れっきょがた、)とは、コンピュータプログラミングにおいて、プログラマが選んだ各々の識別子をそのまま有限のセットとして持つ抽象データ型である。列挙型は一般に番号順を持たないカテゴリ変数(カードの組のように)として使われる。実行時には、列挙型は整数で実装されることが多い(各々の識別子は異なる整数値を持つ)。 (ja)
  • Een enumeratie of opsomming is een datatype in verschillende programmeertalen. (nl)
  • Typ wyliczeniowy - w językach programowania rodzaj typu danych zawierający listę wartości, jakie może przyjmować zmienna tego typu. Typ wyliczeniowy pełni nieocenioną funkcję w Metaprogramowaniu, gdyż pozwala na tworzenie stałych w chwili kompilacji. (pl)
  • em programação, uma enumeração é um tipo de dado abstrato, cujos valores são atribuídos a exatamente um elemento de um conjunto finito de identificadores escolhidos pelo programador. Esse tipo é geralmente usado para variáveis categóricas (como os naipes de um baralho), que não possui uma ordem numérica definida. (pt)
  • Перечисляемый тип (сокращённо перечисле́ние, ) — в программировании тип данных, чьё множество значений представляет собой ограниченный список идентификаторов. (ru)
rdfs:label
  • Enumerated type (en)
  • Aufzählungstyp (de)
  • 列挙型 (ja)
  • Enumeratie (datatype) (nl)
  • Typ wyliczeniowy (pl)
  • Enumeração (tipo de dado) (pt)
  • Перечислимый тип (ru)
skos:subject
foaf:page
p:redirect
owl:sameAs