Name: Anonymous 2012-02-03 19:19
if (a == 0){
}. . . Did this make anyone else rage?
if (a == 0){
}if (!a) {
}if (a == 0) {
}if (0 == a)
{
}
if ((a < 0) == 0 && (a > 0) == 0) {
}
!a when the major distinction is between a being zero or nonzero (e.g. strcmp for equality) and a == 0 when zero is just another value (e.g. the file descriptor of stdin).
(!(strcmp(a, b)))
if(a == 0) { }'
>parentheses around expressions
>2012
if(a != null) would be faster
#define U_MAD(op) (a == 0 || a != 0)
if (U_MAD(a)) {
}
a = p ‽ fish ·· maybe;
if (a != 0)
{
throw non_zero_exception();
}
else
{
}
#include <exception>
#include <stdio.h>
#include <stdlib.h>
class EnterpriseSwitchCaseBase : public std::exception {
public:
int n;
virtual void Throw() { throw this; };
};
static EnterpriseSwitchCaseBase **EnterpriseArray = NULL;
static int EnterpriseArrayElements = 0;
std::exception *EnterpriseSwitchSet(int n, EnterpriseSwitchCaseBase *e) {
e->n = n;
if(EnterpriseArray) {
if(EnterpriseArrayElements < n) {
EnterpriseArrayElements = n + 1;
EnterpriseArray = (EnterpriseSwitchCaseBase**)realloc(EnterpriseArray,EnterpriseArrayElements*sizeof(std::exception*));
}
} else {
EnterpriseArrayElements = n + 1;
EnterpriseArray = (EnterpriseSwitchCaseBase**)malloc(EnterpriseArrayElements*sizeof(std::exception*));
}
EnterpriseArray[n] = e;
return NULL;
}
#define ENTERPRISE_INT_SWITCH_DEFINE_CASE(N) class EnterpriseSwitchCase ## N : public EnterpriseSwitchCaseBase {public: virtual void Throw() { throw (EnterpriseSwitchCase ## N *)this; } };\
static void *EnterpriseSwitchVariable ## N = EnterpriseSwitchSet(N,new EnterpriseSwitchCase ## N());
#define ENTERPRISE_INT_SWITCH(N) try { EnterpriseIntSwitch(N);
#define ENTERPRISE_INT_SWITCH_CASE(N) } catch(EnterpriseSwitchCase ## N *ex) {
#define ENTERPRISE_INT_SWITCH_DEFAULT } catch(EnterpriseSwitchCaseBase *ex) {
#define ENTERPRISE_INT_SWITCH_END }
void EnterpriseIntSwitch(int EnterpriseIntSwitchValue) {
if(EnterpriseArray[EnterpriseIntSwitchValue]) {
EnterpriseArray[EnterpriseIntSwitchValue]->Throw();
}
EnterpriseSwitchCaseBase e;
e.Throw();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
ENTERPRISE_INT_SWITCH_DEFINE_CASE(10)
ENTERPRISE_INT_SWITCH_DEFINE_CASE(20)
int main(int argc, char **argv) {
if(!argv[1]) {
printf("moar args plz!\n");
return 1;
}
int i = atoi(argv[1]);
ENTERPRISE_INT_SWITCH(i)
ENTERPRISE_INT_SWITCH_CASE(10)
printf("CASE 10!\n");
ENTERPRISE_INT_SWITCH_CASE(20)
printf("CASE 20!\n");
ENTERPRISE_INT_SWITCH_DEFAULT
printf("DEFAULT\n");
ENTERPRISE_INT_SWITCH_END
return 0;
}
ComparisonEvaluatorFactory factory = new ComparisonEvaluatorFactory.getSingleton();
ComparisonEvaluator comparisonEvaluator = factory.create(ComparisonEvaluatorFactor.DEFAULT);
EqualityComparison eq = comparisonEvaluator.createEqualityComparison();
eq.add(new Integer(a));
eq.add(new Integer(0));
ComparisonGroup group = new ComparisonGroup(ComparisonGroup.AND);
group.addComparison(eq);
comparisonEvaluator.setComparisonGroup(group);
if (comparisonEvaluator.evaluate()) {
}