text:
package com.example.myshop.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.widget.Button;

import com.example.myshop.R;
import com.example.myshop.bean.ShoppingCart;
import com.example.myshop.bean.Wares;
import com.example.myshop.utils.CartProvider;
import com.example.myshop.utils.LogUtil;
import com.example.myshop.utils.ToastUtils;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

/**
 * Created by Bei on 2016/9/24.
 * 适用于HotFragment中RecyclerView的Adapter
 */

public class HWAdatper extends SimpleAdapter<Wares> {

    private CartProvider cartProvider;

    public HWAdatper(Context context, List<Wares> datas) {
        super(context, R.layout.template_hot_wares, datas);
        cartProvider = new CartProvider(context);
    }

    @Override
    public void bindData(BaseViewHolder viewHolder, final Wares wares) {

        SimpleDraweeView draweeView = (SimpleDraweeView) viewHolder.getView(R.id.drawee_view);
        draweeView.setImageURI(Uri.parse(wares.getImgUrl()));

        viewHolder.getTextView(R.id.text_title).setText(wares.getName());

        Button button = viewHolder.getButton(R.id.btn_add);
        if (button != null) {
            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    cartProvider.put(wares);

                    ToastUtils.show(context, "已添加到购物车");
                }
            });
        }
    }

    /**
     * 重新设置页面布局
     * @param layoutId 布局视图id
     */
    public void  resetLayout(int layoutId){
        this.layoutResId  = layoutId;
        notifyItemRangeChanged(0,getDatas().size());
    }
}


text:
@implementation YJInfoHeaderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
	if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
		self.contentView.backgroundColor = [UIColor whiteColor];
		UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 180)];
		[self.contentView addSubview:imageView];
		self.icon = imageView;

		self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 160, SCREENWIDTH, 20)];
		self.titleLabel.textAlignment = NSTextAlignmentCenter;
		self.titleLabel.font = [UIFont systemFontOfSize:16.0f];
		self.titleLabel.textColor = [UIColor blackColor];
		[self.icon addSubview:self.titleLabel];

	}
	return self;
}
@end

redpajama_set_name: RedPajamaGithub


text:
struct TripAlight {
    edgepayload_t type;
    long external_id;
    State* (*walk)(struct EdgePayload*, struct State*, struct WalkOptions*);
    State* (*walkBack)(struct EdgePayload*, struct State*, struct WalkOptions*);

    int n;
    int* arrivals;
    char** trip_ids;
    int* stop_sequences;

    ServiceCalendar* calendar;
    Timezone* timezone;
    int agency;
    ServiceId service_id;

    int overage; //number of seconds schedules past midnight of the last departure. If it's at 12:00:00, the overage is 0.
} ;

TripAlight*
alNew( ServiceId service_id, ServiceCalendar* calendar, Timezone* timezone, int agency );

void
alDestroy(TripAlight* this);

ServiceCalendar*
alGetCalendar( TripAlight* this );

Timezone*
alGetTimezone( TripAlight* this );

int
alGetAgency( TripAlight* this );

ServiceId
alGetServiceId( TripAlight* this );

int
alGetNumAlightings(TripAlight* this);

void
alAddAlighting(TripAlight* this, char* trip_id, int arrival, int stop_sequence);

char*
alGetAlightingTripId(TripAlight* this, int i);

int
alGetAlightingArrival(TripAlight* this, int i);

int
alGetAlightingStopSequence(TripAlight* this, int i);

int
alSearchAlightingsList(TripAlight* this, int time);

int
alGetLastAlightingIndex(TripAlight* this, int time);

int
alGetOverage(TripAlight* this);

int
alGetAlightingIndexByTripId(TripAlight* this, char* trip_id);

inline State*
alWalk(EdgePayload* this, State* state, WalkOptions* options);

inline State*
alWalkBack(EdgePayload* this, State* state, WalkOptions* options);

#endif


text:
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 317663 $ -->
<refentry xml:id="function.event-buffer-write" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>event_buffer_write</refname>
  <refpurpose>Write data to a buffered event</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>event_buffer_write</methodname>
   <methodparam><type>resource</type><parameter>bevent</parameter></methodparam>
   <methodparam><type>string</type><parameter>data</parameter></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>data_size</parameter><initializer>-1</initializer></methodparam>
  </methodsynopsis>
  <para>
   Writes data to the specified buffered event. The data is appended to the
   output buffer and written to the descriptor when it becomes available for
   writing.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>bevent</parameter></term>
     <listitem>
      <para>
       Valid buffered event resource.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>data</parameter></term>
     <listitem>
      <para>
       The data to be written.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>data_size</parameter></term>
     <listitem>
      <para>
       Optional size parameter. <function>event_buffer_write</function> writes
       all the <parameter>data</parameter> by default.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   <function>event_buffer_write</function> returns &true; on success or &false; on error.
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->


text:
'use strict';
module.exports = (bot) => {
  bot.hear('help', (payload, chat) => {
    const text = payload.message.text;
    const buttons = [
      { type: 'postback', title: 'Settings', payload: 'HELP_SETTINGS' },
      { type: 'postback', title: 'Notifications', payload: 'HELP_NOTIFICATIONS' }
    ];
    chat.sendButtonTemplate(`Need help? Try one of these options`, buttons);
  });
};


text:
from __future__ import absolute_import
from tvtk.code_gen import *


text:
{% extends 'base.html' %}
{% load i18n %}
{% load url from future %}

{% block title %}{% trans "Log In" %}{% endblock %}

{% block content %}

<form action="" method="post">
  {% csrf_token %}
  <fieldset>
     <legend>{% trans "Log In" %}</legend>
     {{ form.non_field_errors }}
     {% for field in form %}
     {{ field.errors }}
     {% comment %} Displaying checkboxes differently {% endcomment %}
     {% if field.name == 'remember_me' %}
        {{ field }}
     {% else %}

        {{ field.label_tag }}
        {{ field }}

     {% endif %}
  {% endfor %}
  {% if stashed %}
     <input type="hidden" value="{{stash_id}}" />
  {% endif %}
  </fieldset>

<input class= "btn btn-primary" type="submit" value="{% trans "Log In" %}" />

Or

  {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
</form>

{% trans "Forgot your password?" %}

Or {% trans "Create an Account" %}

{% endblock %}


text:
'use strict';

//  In this file, we show how ES6 uses 'syntactic sugar'(a feature that makes typing/reading commands easier, but does not change
//    how things are implemented under the hood) to implement creation of classes.
class Person {
    //  Anything you add to the function constructor below is automatically put on each object you call 'new Person()' for (create).
    constructor(firstname, lastname) {
        this.firstname = firstname;
        this.lastname = lastname;
    }
    //  Anything you add to the class, but outside of the function constructor, is automatically put on the prototype.
    greet() {
        console.log('Hello, ' + this.firstname + ' ' + this.lastname);
    }
}

/*  This was how we used a function constructor in previous examples to create objects.  Replaced by 'constructor(firstname, lastname)'
function Person(firstname, lastname) {
    this.firstname = firstname;
    this.lastname = lastname;
}
*/
/*  This was how we added functions to the prototype in previous examples.  Replaced by 'greet()' within 'class Person' declaration.
Person.prototype.greet = function() {
    console.log('Hello, ' + this.firstname + ' ' + this.lastname);
};
*/

var john = new Person('John', 'Doe');
john.greet();

var jane = new Person('Jane', 'Doe');
jane.greet();

console.log(john.__proto__);
console.log(jane.__proto__);
console.log(john.__proto__ === jane.__proto__);


text:
@interface OrgApacheLuceneUtilAutomatonMinimizationOperations ()

- (instancetype)init;

@end

__attribute__((unused)) static void OrgApacheLuceneUtilAutomatonMinimizationOperations_init(OrgApacheLuceneUtilAutomatonMinimizationOperations *self);

__attribute__((unused)) static OrgApacheLuceneUtilAutomatonMinimizationOperations *new_OrgApacheLuceneUtilAutomatonMinimizationOperations_init(void) NS_RETURNS_RETAINED;

__attribute__((unused)) static OrgApacheLuceneUtilAutomatonMinimizationOperations *create_OrgApacheLuceneUtilAutomatonMinimizationOperations_init(void);

@implementation OrgApacheLuceneUtilAutomatonMinimizationOperations

J2OBJC_IGNORE_DESIGNATED_BEGIN
- (instancetype)init {
  OrgApacheLuceneUtilAutomatonMinimizationOperations_init(self);
  return self;
}
J2OBJC_IGNORE_DESIGNATED_END

+ (OrgApacheLuceneUtilAutomatonAutomaton *)minimizeWithOrgApacheLuceneUtilAutomatonAutomaton:(OrgApacheLuceneUtilAutomatonAutomaton *)a
                                                                                withInt:(jint)maxDeterminizedStates {
  return OrgApacheLuceneUtilAutomatonMinimizationOperations_minimizeWithOrgApacheLuceneUtilAutomatonAutomaton_withInt_(a, maxDeterminizedStates);
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x2, -1, -1, -1, -1, -1, -1 },
    { NULL, "LOrgApacheLuceneUtilAutomatonAutomaton;", 0x9, 0, 1, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(init);
  methods[1].selector = @selector(minimizeWithOrgApacheLuceneUtilAutomatonAutomaton:withInt:);
  #pragma clang diagnostic pop
  static const void *ptrTable[] = { "minimize", "LOrgApacheLuceneUtilAutomatonAutomaton;I", "LOrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair;LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList;LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode;" };
  static const J2ObjcClassInfo _OrgApacheLuceneUtilAutomatonMinimizationOperations = { "MinimizationOperations", "org.apache.lucene.util.automaton", ptrTable, methods, NULL, 7, 0x11, 2, 0, -1, 2, -1, -1, -1 };
  return &_OrgApacheLuceneUtilAutomatonMinimizationOperations;
}

@end

void OrgApacheLuceneUtilAutomatonMinimizationOperations_init(OrgApacheLuceneUtilAutomatonMinimizationOperations *self) {
  NSObject_init(self);
}

OrgApacheLuceneUtilAutomatonMinimizationOperations *new_OrgApacheLuceneUtilAutomatonMinimizationOperations_init() {
  J2OBJC_NEW_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations, init)
}

OrgApacheLuceneUtilAutomatonMinimizationOperations *create_OrgApacheLuceneUtilAutomatonMinimizationOperations_init() {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations, init)
}

OrgApacheLuceneUtilAutomatonAutomaton *OrgApacheLuceneUtilAutomatonMinimizationOperations_minimizeWithOrgApacheLuceneUtilAutomatonAutomaton_withInt_(OrgApacheLuceneUtilAutomatonAutomaton *a, jint maxDeterminizedStates) {
  OrgApacheLuceneUtilAutomatonMinimizationOperations_initialize();
  if ([((OrgApacheLuceneUtilAutomatonAutomaton *) nil_chk(a)) getNumStates] == 0 || ([a isAcceptWithInt:0] == false && [a getNumTransitionsWithInt:0] == 0)) {
    return create_OrgApacheLuceneUtilAutomatonAutomaton_init();
  }
  a = OrgApacheLuceneUtilAutomatonOperations_determinizeWithOrgApacheLuceneUtilAutomatonAutomaton_withInt_(a, maxDeterminizedStates);
  if ([((OrgApacheLuceneUtilAutomatonAutomaton *) nil_chk(a)) getNumTransitionsWithInt:0] == 1) {
    OrgApacheLuceneUtilAutomatonTransition *t = create_OrgApacheLuceneUtilAutomatonTransition_init();
    [a getTransitionWithInt:0 withInt:0 withOrgApacheLuceneUtilAutomatonTransition:t];
    if (t->dest_ == 0 && t->min_ == JavaLangCharacter_MIN_CODE_POINT && t->max_ == JavaLangCharacter_MAX_CODE_POINT) {
      return a;
    }
  }
  a = OrgApacheLuceneUtilAutomatonOperations_totalizeWithOrgApacheLuceneUtilAutomatonAutomaton_(a);
  IOSIntArray *sigma = [((OrgApacheLuceneUtilAutomatonAutomaton *) nil_chk(a)) getStartPoints];
  jint sigmaLen = ((IOSIntArray *) nil_chk(sigma))->size_;
  jint statesLen = [a getNumStates];
  IOSObjectArray *reverse = [IOSObjectArray arrayWithDimensions:2 lengths:(jint[]){ statesLen, sigmaLen } type:JavaUtilArrayList_class_()];
  IOSObjectArray *partition = [IOSObjectArray arrayWithLength:statesLen type:JavaUtilHashSet_class_()];
  IOSObjectArray *splitblock = [IOSObjectArray arrayWithLength:statesLen type:JavaUtilArrayList_class_()];
  IOSIntArray *block = [IOSIntArray arrayWithLength:statesLen];
  IOSObjectArray *active = [IOSObjectArray arrayWithDimensions:2 lengths:(jint[]){ statesLen, sigmaLen } type:OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_class_()];
  IOSObjectArray *active2 = [IOSObjectArray arrayWithDimensions:2 lengths:(jint[]){ statesLen, sigmaLen } type:OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode_class_()];
  JavaUtilLinkedList *pending = create_JavaUtilLinkedList_init();
  JavaUtilBitSet *pending2 = create_JavaUtilBitSet_initWithInt_(sigmaLen * statesLen);
  JavaUtilBitSet *split = create_JavaUtilBitSet_initWithInt_(statesLen);
  JavaUtilBitSet *refine = create_JavaUtilBitSet_initWithInt_(statesLen);
  JavaUtilBitSet *refine2 = create_JavaUtilBitSet_initWithInt_(statesLen);
  for (jint q = 0; q < statesLen; q++) {
    IOSObjectArray_SetAndConsume(splitblock, q, new_JavaUtilArrayList_init());
    IOSObjectArray_SetAndConsume(partition, q, new_JavaUtilHashSet_init());
    for (jint x = 0; x < sigmaLen; x++) {
      IOSObjectArray_SetAndConsume(nil_chk(IOSObjectArray_Get(active, q)), x, new_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_init());
    }
  }
  for (jint q = 0; q < statesLen; q++) {
    jint j = [a isAcceptWithInt:q] ? 0 : 1;
    [((JavaUtilHashSet *) nil_chk(IOSObjectArray_Get(partition, j))) addWithId:JavaLangInteger_valueOfWithInt_(q)];
    *IOSIntArray_GetRef(block, q) = j;
    for (jint x = 0; x < sigmaLen; x++) {
      IOSObjectArray *r = IOSObjectArray_Get(reverse, [a stepWithInt:q withInt:IOSIntArray_Get(sigma, x)]);
      if (IOSObjectArray_Get(nil_chk(r), x) == nil) {
        IOSObjectArray_SetAndConsume(r, x, new_JavaUtilArrayList_init());
      }
      [((JavaUtilArrayList *) nil_chk(IOSObjectArray_Get(r, x))) addWithId:JavaLangInteger_valueOfWithInt_(q)];
    }
  }
  for (jint j = 0; j <= 1; j++) {
    for (jint x = 0; x < sigmaLen; x++) {
      for (JavaLangInteger *boxed__ in nil_chk(IOSObjectArray_Get(partition, j))) {
        jint q = [((JavaLangInteger *) nil_chk(boxed__)) intValue];
        if (IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(reverse, q)), x) != nil) {
          IOSObjectArray_Set(nil_chk(IOSObjectArray_Get(active2, q)), x, [((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, j)), x))) addWithInt:q]);
        }
      }
    }
  }
  for (jint x = 0; x < sigmaLen; x++) {
    jint j = (((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, 0)), x)))->size_ <= ((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, 1)), x)))->size_) ? 0 : 1;
    [pending addWithId:create_OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair_initWithInt_withInt_(j, x)];
    [pending2 setWithInt:x * statesLen + j];
  }
  jint k = 2;
  while (![pending isEmpty]) {
    OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair *ip = [pending removeFirst];
    jint p = ((OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair *) nil_chk(ip))->n1_;
    jint x = ip->n2_;
    [pending2 clearWithInt:x * statesLen + p];
    for (OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *m = JreRetainedLocalValue(((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, p)), x)))->first_); m != nil; m = m->next_) {
      JavaUtilArrayList *r = IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(reverse, m->q_)), x);
      if (r != nil) {
        for (JavaLangInteger *boxed__ in r) {
          jint i = [((JavaLangInteger *) nil_chk(boxed__)) intValue];
          if (![split getWithInt:i]) {
            [split setWithInt:i];
            jint j = IOSIntArray_Get(block, i);
            [((JavaUtilArrayList *) nil_chk(IOSObjectArray_Get(splitblock, j))) addWithId:JavaLangInteger_valueOfWithInt_(i)];
            if (![refine2 getWithInt:j]) {
              [refine2 setWithInt:j];
              [refine setWithInt:j];
            }
          }
        }
      }
    }
    for (jint j = [refine nextSetBitWithInt:0]; j >= 0; j = [refine nextSetBitWithInt:j + 1]) {
      JavaUtilArrayList *sb = IOSObjectArray_Get(splitblock, j);
      if ([((JavaUtilArrayList *) nil_chk(sb)) size] < [((JavaUtilHashSet *) nil_chk(IOSObjectArray_Get(partition, j))) size]) {
        JavaUtilHashSet *b1 = IOSObjectArray_Get(partition, j);
        JavaUtilHashSet *b2 = IOSObjectArray_Get(partition, k);
        for (JavaLangInteger *boxed__ in sb) {
          jint s = [((JavaLangInteger *) nil_chk(boxed__)) intValue];
          [((JavaUtilHashSet *) nil_chk(b1)) removeWithId:JavaLangInteger_valueOfWithInt_(s)];
          [((JavaUtilHashSet *) nil_chk(b2)) addWithId:JavaLangInteger_valueOfWithInt_(s)];
          *IOSIntArray_GetRef(block, s) = k;
          for (jint c = 0; c < sigmaLen; c++) {
            OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *sn = IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active2, s)), c);
            if (sn != nil && JreObjectEqualsEquals(sn->sl_, IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, j)), c))) {
              [sn remove];
              IOSObjectArray_Set(nil_chk(IOSObjectArray_Get(active2, s)), c, [((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, k)), c))) addWithInt:s]);
            }
          }
        }
        for (jint c = 0; c < sigmaLen; c++) {
          jint aj = ((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, j)), c)))->size_;
          jint ak = ((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(IOSObjectArray_Get(nil_chk(IOSObjectArray_Get(active, k)), c)))->size_;
          jint ofs = c * statesLen;
          if (![pending2 getWithInt:ofs + j] && 0 < aj && aj <= ak) {
            [pending2 setWithInt:ofs + j];
            [pending addWithId:create_OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair_initWithInt_withInt_(j, c)];
          }
          else {
            [pending2 setWithInt:ofs + k];
            [pending addWithId:create_OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair_initWithInt_withInt_(k, c)];
          }
        }
        k++;
      }
      [refine2 clearWithInt:j];
      for (JavaLangInteger *boxed__ in sb) {
        jint s = [((JavaLangInteger *) nil_chk(boxed__)) intValue];
        [split clearWithInt:s];
      }
      [sb clear];
    }
    [refine clear];
  }
  OrgApacheLuceneUtilAutomatonAutomaton *result = create_OrgApacheLuceneUtilAutomatonAutomaton_init();
  OrgApacheLuceneUtilAutomatonTransition *t = create_OrgApacheLuceneUtilAutomatonTransition_init();
  IOSIntArray *stateMap = [IOSIntArray arrayWithLength:statesLen];
  IOSIntArray *stateRep = [IOSIntArray arrayWithLength:k];
  [result createState];
  for (jint n = 0; n < k; n++) {
    jboolean isInitial = false;
    for (JavaLangInteger *boxed__ in nil_chk(IOSObjectArray_Get(partition, n))) {
      jint q = [((JavaLangInteger *) nil_chk(boxed__)) intValue];
      if (q == 0) {
        isInitial = true;
        break;
      }
    }
    jint newState;
    if (isInitial) {
      newState = 0;
    }
    else {
      newState = [result createState];
    }
    for (JavaLangInteger *boxed__ in nil_chk(IOSObjectArray_Get(partition, n))) {
      jint q = [((JavaLangInteger *) nil_chk(boxed__)) intValue];
      *IOSIntArray_GetRef(stateMap, q) = newState;
      [result setAcceptWithInt:newState withBoolean:[a isAcceptWithInt:q]];
      *IOSIntArray_GetRef(stateRep, newState) = q;
    }
  }
  for (jint n = 0; n < k; n++) {
    jint numTransitions = [a initTransitionWithInt:IOSIntArray_Get(stateRep, n) withOrgApacheLuceneUtilAutomatonTransition:t];
    for (jint i = 0; i < numTransitions; i++) {
      [a getNextTransitionWithOrgApacheLuceneUtilAutomatonTransition:t];
      [result addTransitionWithInt:n withInt:IOSIntArray_Get(stateMap, t->dest_) withInt:t->min_ withInt:t->max_];
    }
  }
  [result finishState];
  return OrgApacheLuceneUtilAutomatonOperations_removeDeadStatesWithOrgApacheLuceneUtilAutomatonAutomaton_(result);
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneUtilAutomatonMinimizationOperations)

@implementation OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair

- (instancetype)initWithInt:(jint)n1
                    withInt:(jint)n2 {
  OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair_initWithInt_withInt_(self, n1, n2);
  return self;
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x0, -1, 0, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(initWithInt:withInt:);
  #pragma clang diagnostic pop
  static const J2ObjcFieldInfo fields[] = {
    { "n1_", "I", .constantValue.asLong = 0, 0x10, -1, -1, -1, -1 },
    { "n2_", "I", .constantValue.asLong = 0, 0x10, -1, -1, -1, -1 },
  };
  static const void *ptrTable[] = { "II", "LOrgApacheLuceneUtilAutomatonMinimizationOperations;" };
  static const J2ObjcClassInfo _OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair = { "IntPair", "org.apache.lucene.util.automaton", ptrTable, methods, fields, 7, 0x18, 1, 2, 1, -1, -1, -1, -1 };
  return &_OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair;
}

@end

void OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair_initWithInt_withInt_(OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair *self, jint n1, jint n2) {
  NSObject_init(self);
  self->n1_ = n1;
  self->n2_ = n2;
}

OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair *new_OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair_initWithInt_withInt_(jint n1, jint n2) {
  J2OBJC_NEW_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair, initWithInt_withInt_, n1, n2)
}

OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair *create_OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair_initWithInt_withInt_(jint n1, jint n2) {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair, initWithInt_withInt_, n1, n2)
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneUtilAutomatonMinimizationOperations_IntPair)

@implementation OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList

J2OBJC_IGNORE_DESIGNATED_BEGIN
- (instancetype)init {
  OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_init(self);
  return self;
}
J2OBJC_IGNORE_DESIGNATED_END

- (OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *)addWithInt:(jint)q {
  return create_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode_initWithInt_withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_(q, self);
}

- (void)dealloc {
  RELEASE_(first_);
  RELEASE_(last_);
  [super dealloc];
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x0, -1, -1, -1, -1, -1, -1 },
    { NULL, "LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode;", 0x0, 0, 1, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(init);
  methods[1].selector = @selector(addWithInt:);
  #pragma clang diagnostic pop
  static const J2ObjcFieldInfo fields[] = {
    { "size_", "I", .constantValue.asLong = 0, 0x0, -1, -1, -1, -1 },
    { "first_", "LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode;", .constantValue.asLong = 0, 0x0, -1, -1, -1, -1 },
    { "last_", "LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode;", .constantValue.asLong = 0, 0x0, -1, -1, -1, -1 },
  };
  static const void *ptrTable[] = { "add", "I", "LOrgApacheLuceneUtilAutomatonMinimizationOperations;" };
  static const J2ObjcClassInfo _OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList = { "StateList", "org.apache.lucene.util.automaton", ptrTable, methods, fields, 7, 0x18, 2, 3, 2, -1, -1, -1, -1 };
  return &_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList;
}

@end

void OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_init(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *self) {
  NSObject_init(self);
}

OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *new_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_init() {
  J2OBJC_NEW_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList, init)
}

OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *create_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_init() {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList, init)
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList)

@implementation OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode

- (instancetype)initWithInt:(jint)q
withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList:(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *)sl {
  OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode_initWithInt_withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_(self, q, sl);
  return self;
}

- (void)remove {
  ((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(sl_))->size_--;
  if (JreObjectEqualsEquals(sl_->first_, self)) JreStrongAssign(&sl_->first_, next_);
  else JreStrongAssign(&((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *) nil_chk(prev_))->next_, next_);
  if (JreObjectEqualsEquals(sl_->last_, self)) JreStrongAssign(&sl_->last_, prev_);
  else JreStrongAssign(&((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *) nil_chk(next_))->prev_, prev_);
}

- (void)dealloc {
  RELEASE_(next_);
  RELEASE_(prev_);
  RELEASE_(sl_);
  [super dealloc];
}

+ (const J2ObjcClassInfo *)__metadata {
  static J2ObjcMethodInfo methods[] = {
    { NULL, NULL, 0x0, -1, 0, -1, -1, -1, -1 },
    { NULL, "V", 0x0, -1, -1, -1, -1, -1, -1 },
  };
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wobjc-multiple-method-names"
  #pragma clang diagnostic ignored "-Wundeclared-selector"
  methods[0].selector = @selector(initWithInt:withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList:);
  methods[1].selector = @selector(remove);
  #pragma clang diagnostic pop
  static const J2ObjcFieldInfo fields[] = {
    { "q_", "I", .constantValue.asLong = 0, 0x10, -1, -1, -1, -1 },
    { "next_", "LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode;", .constantValue.asLong = 0, 0x0, -1, -1, -1, -1 },
    { "prev_", "LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode;", .constantValue.asLong = 0, 0x0, -1, -1, -1, -1 },
    { "sl_", "LOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList;", .constantValue.asLong = 0, 0x10, -1, -1, -1, -1 },
  };
  static const void *ptrTable[] = { "ILOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList;", "LOrgApacheLuceneUtilAutomatonMinimizationOperations;" };
  static const J2ObjcClassInfo _OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode = { "StateListNode", "org.apache.lucene.util.automaton", ptrTable, methods, fields, 7, 0x18, 2, 4, 1, -1, -1, -1, -1 };
  return &_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode;
}

@end

void OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode_initWithInt_withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *self, jint q, OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *sl) {
  NSObject_init(self);
  self->q_ = q;
  JreStrongAssign(&self->sl_, sl);
  if (((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *) nil_chk(sl))->size_++ == 0) JreStrongAssign(&sl->first_, JreStrongAssign(&sl->last_, self));
  else {
    JreStrongAssign(&((OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *) nil_chk(sl->last_))->next_, self);
    JreStrongAssign(&self->prev_, sl->last_);
    JreStrongAssign(&sl->last_, self);
  }
}

OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *new_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode_initWithInt_withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_(jint q, OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *sl) {
  J2OBJC_NEW_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode, initWithInt_withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_, q, sl)
}

OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode *create_OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode_initWithInt_withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_(jint q, OrgApacheLuceneUtilAutomatonMinimizationOperations_StateList *sl) {
  J2OBJC_CREATE_IMPL(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode, initWithInt_withOrgApacheLuceneUtilAutomatonMinimizationOperations_StateList_, q, sl)
}

J2OBJC_CLASS_TYPE_LITERAL_SOURCE(OrgApacheLuceneUtilAutomatonMinimizationOperations_StateListNode)


text:
namespace bluedot
{
    template <typename T, typename RNG>
    class FBM {
    public:
        FBM(RNG& rng, size_t width, size_t height, size_t octaves, T exponent = 2.0, bool spherical = true);
        auto operator()(size_t x, size_t y) const -> T;
    private:
        size_t _width;
        size_t _height;
        std::vector<T> _noise;
    };
}

#include "fbm.hpp"


text:
layout: post
title: Making your Bash Shell More Interesting Using Fortune
author: Fred Muya
---

Every time I open a new shell prompt, a message similar to the one below greets me:
{% highlight bash %}
Weekends were made for programming.
- Karl Lehenbauer
muya@ENCORE ~ 00:27:16 $
{% endhighlight %}

The witty message is provided by fortune, and you too can have something similar.

Using your package manager, install `fortune`, e.g. if you use Homebrew on OS X, run:
{% highlight bash %}
$ brew install fortune
{% endhighlight %}

Test installation by running fortune on your command line:
{% highlight bash %}
$ fortune
Universe, n.:
    The problem.
{% endhighlight %}

I suggest you skim through `man fortune` to get your head wrapped around how fortune works. I'll just highlight a few options:

* `-a` - Will select a random epigram that could be or not be offensive
* `-o` - Will select a random epigram that's offensive

Running fortune without a flag just selects a random, non-offensive epigram.

Quoting the man page, use `-a` and `-o` if and only if you believe, deep in your heart, that you are willing to be offended.

Next, adding it to your bash. Edit your bash prompt config file. For some, it's usually `~/.bash_profile`, others, `~/.bashrc`

Add this to the end of the file:
{% highlight bash %}
fortune
# fortune -o if you are willing to be offended
# fortune -a if you are willing to be offended by surprise  ;)
{% endhighlight %}

This means that the command will be run every time the config file is run (which is usually the case when you open a new bash shell)

Save and exit the file, then run `soure ~/.bash_profile`

Now any time you open a shell, a random epigram will be displayed.

Have fun!


text:
from django.contrib import admin
from .models import Presentation, Slide, OrderedSlides

class OrderedSlidesInline(admin.TabularInline):
    model = OrderedSlides
    extra = 1

class PresentationAdmin(admin.ModelAdmin):
    inlines = (OrderedSlidesInline, )

admin.site.register(Presentation, PresentationAdmin)
admin.site.register(Slide)


text:
package com.velvetPearl.lottery.viewModels;

import com.velvetPearl.lottery.dataAccess.models.LotteryNumber;
import com.velvetPearl.lottery.dataAccess.models.Ticket;

import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;

/**
 * Created by Stensig on 13-Oct-16.
 */

public class TicketListViewModel {
    private Ticket entityModel;

    public TicketListViewModel(Ticket entityModel) {
        this.entityModel = entityModel;
    }

    public Object getId() {
        return entityModel.getId();
    }

    public String getOwner() {
        return entityModel.getOwner();
    }

    public ArrayList<Integer> getLotteryNumbers() {
        ArrayList<Integer> result = new ArrayList<>();
        for (LotteryNumber number : entityModel.getLotteryNumbers()) {
            result.add(number.getLotteryNumber());
        }
//        TreeMap<Object, LotteryNumber> lotteryNumbers = entityModel.getLotteryNumbers();
//        for (Object key : lotteryNumbers.keySet()) {
//            result.add(lotteryNumbers.get(key).getLotteryNumber());
//        }
        return result;
    }

    public Ticket getEntityModel() { return entityModel; }

    public double getTotalTicketPrice() {
        double totalPrice = 0.0;
        for (LotteryNumber number : entityModel.getLotteryNumbers()) {
            totalPrice += number.getPrice();
        }
//        TreeMap<Object, LotteryNumber> lotteryNumbers = entityModel.getLotteryNumbers();
//        for (Object key : lotteryNumbers.keySet()) {
//            totalPrice += lotteryNumbers.get(key).getPrice();
//        }
        return totalPrice;
    }

    @Override
    public String toString() {
        return entityModel.getOwner();
    }
}


text:
package org.prcode.business.support.basic.security.util;

import org.apache.log4j.Logger;
import org.prcode.business.support.basic.security.domain.CustomerUserDetail;
import org.prcode.utility.exception.LoginTimeout;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @ClassName: SecurityUtil
 * @Date: 2017-4-16 22:32
 * @Auther: kangduo
 * @Description: (项目中任意位置获取用户信息)
 */
public class SecurityUtil {

    private static final Logger logger = Logger.getLogger(SecurityUtil.class);

    public static final String ACCOUNT_TYPE = "accountType";

    /**
     * 是否授权访问
     * @return
     */
    public static boolean isAuthenticated() {
        return SecurityContextHolder.getContext().getAuthentication().isAuthenticated();
    }

    /**
     * 获取当前用户信息
     * @return
     */
    public static CustomerUserDetail getCustomerUserDetail() {
        CustomerUserDetail userDetail = null;
        try {
            userDetail = (CustomerUserDetail) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        } catch (Exception e) {
            logger.info("当前用户未登录");
        }
        return userDetail;
    }

    /**
     * 获取当前用户ID
     * @return
     */
    public static String getOperId() {
        CustomerUserDetail userDetail = getCustomerUserDetail();
        return userDetail == null ? null : userDetail.getId();
    }

    /**
     * 获取当前用户ID
     * @return
     */
    public static String getOperIdMustExist() throws LoginTimeout {
        CustomerUserDetail userDetail = getCustomerUserDetail();
        if (userDetail == null) {
            throw new LoginTimeout("登录信息已过期");
        }
        return userDetail.getId();
    }

}


text:
if (typeof Storyline === "undefined")
    throw new Error('Storyline is required');

Storyline.Theater = function(initCallback)
{
    // Initialize fields
    this.autoPlay = false;
    this.tickInterval = 50;
    this.tickCheckOverlay = false;
    this.timer = undefined;
    this.playing = false;
    this.library = {};
    this.scenes = [];
    this.currentScene = undefined;
    this._tickRunning = false;
    this.onDraw = undefined;
    this.onPlay = undefined;
    this.onSceneChanged = undefined;
    this.onStop = undefined;
    this.onTick = undefined;

    if (initCallback instanceof Function)
    {
        initCallback.apply(this,[]);
    }

    return this;
}

if (typeof StTheater === "undefined")
    StTheater = Storyline.Theater;

Storyline.Theater.prototype.setTickInterval = function(value)
{
    item.tickInterval = value;
};

Storyline.Theater.prototype.addToLibrary = function(name, clipFactoryName, initCallback)
{
    if (Storyline.clipFactory[clipFactoryName] == undefined)
        throw new StorylineError('Clip class "'+clipFactoryName+'" not found');

    var constructor = Storyline.clipFactory[clipFactoryName];
    var factory = new constructor(this);
    factory.name = name;

    if (initCallback instanceof Function);
        initCallback.apply(factory,[]);

    if (this.library[factory.name] != undefined)
        throw new StorylineError('Library item "'+factory.name+'" already exists');

    this.library[factory.name] = factory;

    return factory;
};

Storyline.Theater.prototype.newScene = function(initCallback)
{
    var scene = new StScene(this);
    this.scenes.push(scene);
    scene.id = this.scenes.length-1;

    if (initCallback instanceof Function)
    {
        scene.name = initCallback.name;
        initCallback.apply(scene,[]);
    }

    if (scene.name != '')
    {
        if (this.scenes[scene.name] != undefined)
            throw new StorylineError('The scene "'+scene.name+'" is reserved or already exists');
        this.scenes[scene.name] = scene;
    }

    return scene;
};

Storyline.Theater.prototype.setFPS = function(fps)
{
    this.tickInterval = Math.round(1000 / fps);
};

Storyline.Theater.prototype.run = function()
{
    if (this.scenes.length <= 0)
        throw new StorylineError('The Theater must have at least one scene before play');

    if (this.autoPlay)
        this.gotoAndPlay(0);
    else
        this.gotoScene(0);
};

Storyline.Theater.prototype._startTimer = function()
{
    this.playing = true;
    this.timer = setInterval(this._timerCallback, this.tickInterval, this);
}

Storyline.Theater.prototype._stopTimer = function()
{
    this.playing = false;
    if (this.timer != undefined)
    {
        clearInterval(this.timer);
        this.timer = undefined;
    }
}

Storyline.Theater.prototype._timerCallback = function(theater)
{
    if (theater.tickCheckOverlay)
    {
        if (theater._tickRunning)
            return;
        theater._tickRunning = true;
    }

    theater.tick();

    if (theater.tickCheckOverlay)
        theater._tickRunning = false;
}

Storyline.Theater.prototype.play = function()
{
    var wasPlaying = this.playing;
    this._startTimer();

    if (! wasPlaying)
        this.doPlay();
};

Storyline.Theater.prototype.stop = function()
{
    var wasPlaying = this.playing;
    this._stopTimer();

    if (wasPlaying)
        this.doStop();
};

Storyline.Theater.prototype.tick = function()
{
    this.doTick();
    this.doDraw();
};

Storyline.Theater.prototype.gotoScene = function(sceneName, frameNum)
{
    var wasPlaying = this.playing;
    this._stopTimer();
    if (this.currentScene != undefined)
        this.currentScene.doFinish();

    if (this.scenes[sceneName] == undefined)
        throw new StorylineError('Scene "'+sceneName+'" not found');
    this.currentScene = this.scenes[sceneName];
    this.currentScene.doStart();

    if (frameNum != undefined)
        this.currentScene.setFrame(frameNum);
    else
        this.currentScene.setFrame(0);

    if (wasPlaying)
        this._startTimer();
};

Storyline.Theater.prototype.nextScene = function()
{
    if (this.currentScene == undefined)
        this.gotoScene(0);
    else
    {
        var id = this.currentScene.id + 1;
        if (this.scenes[id] != undefined)
            this.gotoScene(id);
        else
            this.gotoScene(0);
    }
}

Storyline.Theater.prototype.prevScene = function()
{
    if (this.currentScene == undefined)
        this.gotoScene(0);
    else
    {
        var id = this.currentScene.id - 1;
        if (this.scenes[id] != undefined)
            this.gotoScene(id);
        else
            this.gotoScene(this.scenes.length-1);
    }
}

Storyline.Theater.prototype.gotoAndPlay = function(sceneName, frameNum)
{
    this._stopTimer();
    this.gotoScene(scene,frameNum);
    this.play();
};

Storyline.Theater.prototype.gotoAndStop = function(sceneName, frameNum)
{
    this._stopTimer();
    this.gotoScene(scene,frameNum);
    this.stop();
};

Storyline.Theater.prototype.doDraw = function()
{
    if (this.onDraw instanceof Function)
        this.onDraw();

    for (var i=0; i<this.scenes; i++)
        this.scenes[i].doDraw();
};

Storyline.Theater.prototype.doPlay = function()
{
    if (this.onPlay instanceof Function)
        this.onPlay();
};

Storyline.Theater.prototype.doSceneChanged = function()
{
    if (this.onSceneChanged instanceof Function)
        this.onSceneChanged();
};

Storyline.Theater.prototype.doStop = function()
{
    if (this.onStop instanceof Function)
        this.onStop();
};

Storyline.Theater.prototype.doTick = function()
{
    if (this.onTick instanceof Function)
        this.onTick();

    for (var i=0; i<this.scenes.length; i++)
        this.scenes[i].doTick();
};


text:
package Armadillo.Communication.Impl.Distributed;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import org.joda.time.DateTime;
import org.joda.time.Minutes;

import Armadillo.Core.Config;
import Armadillo.Core.Console;
import Armadillo.Core.HCException;
import Armadillo.Core.Logger;
import Armadillo.Core.ObjectWrapper;
import Armadillo.Communication.Impl.SimpleUiSocket;
import Armadillo.Communication.Impl.ReqResp.ReqRespService;
import Armadillo.Communication.Impl.ReqResp.ZmqReqRespClient;
import Armadillo.Communication.Impl.Topic.SubscriberCallbackDel;
import Armadillo.Communication.Impl.Topic.TopicMessage;
import Armadillo.Communication.Impl.Topic.TopicSubscriberCache;
import Armadillo.Core.Concurrent.ThreadWorker;
import Armadillo.Core.SelfDescribing.ASelfDescribingClass;
import Armadillo.Core.Text.StringHelper;

public class DistWorker {

	public int Threads;
    public String GridTopic;
    public int JobsInProgress;
    public String ServerName;
    public DistTopicQueue DistTopicQueue;

    public int JobsCompleted()
    {
        return JobsCompletedMap.size();
    }

    public String WorkerId;
    public static boolean IsConnected;
    public DistWorkerToContollerHeartBeat DistWorkerToContollerHeartBeat;
    public ConcurrentHashMap<String, DateTime> JobsCompletedMap;
    public HashSet<String> CalcTypesSet;
    public ConcurrentHashMap<String, Object> m_jobsToDo;
    private static final Object m_connectionLock = new Object();
    private DistWorkerResultSender m_distWorkerResultSender;
    private final Object m_progressLock = new Object();
    private ThreadWorker<ObjectWrapper> m_clockTickWorker;
    private DistWorkerJobPull m_distWorkerJobPull;
    private static int m_intWorkerCounter;
    private static final Object m_couterLock = new Object();
    private ThreadWorker<ObjectWrapper> m_jobsDoneFlusherWorker;

    public static DistWorker OwnInstance;

    private DistWorker(
        String strServerName)
    {
    	try{
	        ServerName = strServerName;
	        JobsCompletedMap = new ConcurrentHashMap<String, DateTime>();

	        Threads = Integer.parseInt(Config.getStringStatic(
	        		"CalcThreads",
	        		SimpleUiSocket.class));
	        String strTopicFromConfig = Config.getStringStatic(
	        		"CalcTopic",
	        		SimpleUiSocket.class);

	        CalcTypesSet = new HashSet<String>();
	        GridTopic = strTopicFromConfig;

	        if(StringHelper.IsNullOrEmpty(GridTopic))
	        {
	            throw new HCException("Empty grid topic");
	        }

	        synchronized(m_couterLock){
	        	m_intWorkerCounter++;
	        }

	        WorkerId = "Worker_" +
	                Config.getClientName() + "_" +
	                GridTopic + "_" +
	                m_intWorkerCounter;

	        m_jobsToDo = new ConcurrentHashMap<String, Object>();

	        DistTopicQueue = new DistTopicQueue(strServerName);
	        SubscribeToTopics();
	        DistWorkerToContollerHeartBeat = new DistWorkerToContollerHeartBeat(this);
	        SetupThreadWorker();
	        m_distWorkerResultSender = new DistWorkerResultSender(this);
	        m_distWorkerJobPull = new DistWorkerJobPull(this);

	        m_jobsDoneFlusherWorker = new ThreadWorker<ObjectWrapper>(){

	        	@Override
	        	public void runTask(ObjectWrapper item) {

	        		try{

	        			while(true){

	        				try{

	        					if(JobsCompletedMap.size() > (int)10e3){

	        						ArrayList<String> jobsToRemove = new ArrayList<String>();
	        						for(Entry<String, DateTime> kvp : JobsCompletedMap.entrySet()){

	        							int intMins = Minutes.minutesBetween(
	        									kvp.getValue(), DateTime.now()).getMinutes();
	        							if(intMins > 30){
	        								jobsToRemove.add(kvp.getKey());
	        							}
	        						}

	        						if(jobsToRemove.size() > 0){

	        							for(String strJobId : jobsToRemove){

	        								JobsCompletedMap.remove(strJobId);
	        							}
	        						}
	        					}
	        				}
	        				catch(Exception ex){

	        					Logger.log(ex);
	        				}

	        				Thread.sleep(60000);
	        			}
	        		}
	        		catch(Exception ex){

	        			Logger.log(ex);
	        		}
	        	}
	        };
	        m_jobsDoneFlusherWorker.work();

	        //
	        // log connection
	        //
	        String strMessage = getClass().getName() + " is connected to [" + strServerName +
	                "] via topic [" + strTopicFromConfig + "]";
	        Console.writeLine(strMessage);
	        Logger.log(strMessage);
    	}
    	catch(Exception ex){
    		Logger.log(ex);
    	}
    }

    private void SetupThreadWorker()
    {
        m_clockTickWorker = new ThreadWorker<ObjectWrapper>(){
        	@Override
        	public void runTask(ObjectWrapper item) {
        		while (true)
                {
                    try
                    {
                        OnClockTick();
                        Thread.sleep(DistConstants.WORKER_PUBLISH_GUI_TIME_SECS*1000);
                    }
                    catch (Exception ex)
                    {
                        Logger.log(ex);
                    }
                }
        	}
        };
        m_clockTickWorker.work();
    }

    public static void Connect(String strServerName)
    {
        if (IsConnected)
        {
            return;
        }
        synchronized (m_connectionLock)
        {
            if (IsConnected)
            {
                return;
            }
            OwnInstance = new DistWorker(
                strServerName);
            IsConnected = true;
            Logger.log(OwnInstance.getClass().getName() + " is now connected. Id = " +
                OwnInstance.WorkerId);
        }
    }

    private void OnClockTick()
    {
        DistGuiHelper.PublishWorkerStats(this);
    }

    private void SubscribeToTopics()
    {
        try
        {
            TopicSubscriberCache.GetSubscriber(ServerName).Subscribe(
                GridTopic + EnumDistributed.JobsDoneTopic.toString(),
                new SubscriberCallbackDel(){
                	@Override
                	public void invoke(TopicMessage topicMessage) {
                		OnTopicControllerJobsDone(topicMessage);
                	}
                });
        }
        catch (Exception ex)
        {
            Logger.log(ex);
        }
    }

    private void OnTopicControllerJobsDone(
        TopicMessage topicmessage)
    {
        String strJobId = (String) topicmessage.EventData;
        JobsCompletedMap.put(strJobId, DateTime.now());
    }

    public void DoJob(
        String strJobId,
        ASelfDescribingClass selfDescribingClass)
    {
        try
        {
            DateTime workTimeLog = DateTime.now();
            synchronized (m_progressLock)
            {
                JobsInProgress++;
            }

            m_jobsToDo.put(strJobId, new Object());

            DistGuiHelper.PublishWorkerLog(this, "Runnning jobs params [" +
                                                 selfDescribingClass + "]");

            String strParentId = selfDescribingClass.GetStrValue(EnumDistributed.ControllerId);

            @SuppressWarnings("unchecked")
			List<Object> params = (List<Object>) selfDescribingClass.GetObjValue("Params");
			String strMethodId = selfDescribingClass.GetStrValue("Request");
			List<Object> result = ReqRespService.ExecuteMethod(strMethodId, params);
            //
            // send result
            //
            boolean blnResultIsSent = m_distWorkerResultSender.SendResult(
            		result,
                strParentId,
                strJobId);

            if (blnResultIsSent)
            {
                DistGuiHelper.PublishWorkerLog(this, "Sent result. JobId [" +
                                                     strJobId + "]");
                JobsCompletedMap.put(strJobId, DateTime.now());
            }
            else
            {
                JobsCompletedMap.remove(strJobId);
                DistGuiHelper.PublishWorkerLog(this, "Could not send result for [" +
                                                     strJobId + "]");
            }

            synchronized (m_progressLock)
            {
                JobsInProgress--;
            }

            DistGuiHelper.PublishWorkerLog(this, "Job [" +
                                                 strJobId + "] done in [" +
                                                 Minutes.minutesBetween(
                                                		 workTimeLog,
                                                		 DateTime.now()).getMinutes() +
                                                 "] mins");
        }
        catch (Exception ex)
        {
            Logger.log(ex);
        }
        finally{
            m_jobsToDo.remove(strJobId);
        }
    }

    public void Dispose()
    {
        if(DistTopicQueue != null)
        {
            DistTopicQueue.Dispose();
            DistTopicQueue = null;
        }

        if(DistWorkerToContollerHeartBeat != null)
        {
            DistWorkerToContollerHeartBeat.Dispose();
            DistWorkerToContollerHeartBeat = null;
        }

        if(JobsCompletedMap != null)
        {
            JobsCompletedMap.clear();
            JobsCompletedMap = null;
        }

        if(CalcTypesSet != null)
        {
            CalcTypesSet.clear();
            CalcTypesSet = null;
        }

        if(m_jobsToDo != null)
        {
            m_jobsToDo.clear();
            m_jobsToDo = null;
        }

        if(m_distWorkerResultSender != null)
        {
            m_distWorkerResultSender.Dispose();
            m_distWorkerResultSender = null;
        }

        if(m_distWorkerJobPull != null)
        {
            m_distWorkerJobPull.Dispose();
            m_distWorkerJobPull = null;
        }

        if(m_clockTickWorker != null)
        {
            m_clockTickWorker.Dispose();
            m_clockTickWorker = null;
        }

        if(m_distWorkerJobPull != null)
        {
            m_distWorkerJobPull.Dispose();
            m_distWorkerJobPull = null;
        }
    }

	public static void loadDistributedWorker()
	{
		try
		{
			String strServerName = Config.getStringStatic(
					"TopicServerName",
					SimpleUiSocket.class);
			final int intReqRespPort = Integer.parseInt(
					Config.getStringStatic("ReqRespPort",
							SimpleUiSocket.class));
			ZmqReqRespClient.Connect(strServerName, intReqRespPort, 5);
			DistWorker.Connect(Config.getStringStatic(
					"TopicServerName",
					SimpleUiSocket.class));
		}
		catch(Exception ex)
		{
			Logger.log(ex);
		}
	}
}


text:
<!DOCTYPE html>

    <title>RTL support</title>
    <meta charset="utf-8">
    <link href="../content/shared/styles/examples-offline.css" rel="stylesheet">
    <link href="../../styles/kendo.common.min.css" rel="stylesheet">
    <link href="../../styles/kendo.rtl.min.css" rel="stylesheet">
    <link href="../../styles/kendo.default.min.css" rel="stylesheet">
    <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet">
    <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet">

        Back

Pick a day:


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>Source code</title>
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

001
031
032package squidpony.performance;
033
034import org.openjdk.jmh.annotations.Benchmark;
035import org.openjdk.jmh.annotations.BenchmarkMode;
036import org.openjdk.jmh.annotations.Mode;
037import org.openjdk.jmh.annotations.OutputTimeUnit;
038import org.openjdk.jmh.runner.Runner;
039import org.openjdk.jmh.runner.RunnerException;
040import org.openjdk.jmh.runner.options.Options;
041import org.openjdk.jmh.runner.options.OptionsBuilder;
042import org.openjdk.jmh.runner.options.TimeValue;
043import squidpony.squidmath.*;
044
045import java.util.concurrent.TimeUnit;
046
047/**
048 * Benchmark                         Mode  Cnt            Score            Error  Units
049 * RNGBenchmark.measureLight         avgt    3   1275059037.000 ±   61737532.875  ns/op
050 * RNGBenchmark.measureLightInt      avgt    3   1278703443.000 ±   66201423.790  ns/op
051 * RNGBenchmark.measureLightIntR     avgt    3   1427303028.000 ±  200958011.322  ns/op
052 * RNGBenchmark.measureLightR        avgt    3   1269081959.667 ±   86190018.925  ns/op
053 * RNGBenchmark.measureMT            avgt    3  43085766002.333 ± 2268888793.171  ns/op
054 * RNGBenchmark.measureMTInt         avgt    3  22167143778.000 ±  828756142.658  ns/op
055 * RNGBenchmark.measureMTIntR        avgt    3  22132403458.000 ±  383655518.387  ns/op
056 * RNGBenchmark.measureMTR           avgt    3  43006069307.000 ± 2473850311.634  ns/op
057 * RNGBenchmark.measurePermuted      avgt    3   1637032592.333 ±   59199840.006  ns/op
058 * RNGBenchmark.measurePermutedInt   avgt    3   1734496732.000 ±   93718940.208  ns/op
059 * RNGBenchmark.measurePermutedIntR  avgt    3   1737075300.667 ±  241897619.330  ns/op
060 * RNGBenchmark.measurePermutedR     avgt    3   1668389798.667 ±  378429094.045  ns/op
061 * RNGBenchmark.measureRandom        avgt    3  22703702167.000 ±  392502237.818  ns/op
062 * RNGBenchmark.measureRandomInt     avgt    3  12593739050.667 ±  197683615.906  ns/op
063 * RNGBenchmark.measureXor           avgt    3   1384086605.000 ±  174305317.575  ns/op
064 * RNGBenchmark.measureXorInt        avgt    3   1276688870.167 ±  133364204.061  ns/op
065 * RNGBenchmark.measureXorIntR       avgt    3   1214642941.833 ±   51259344.714  ns/op
066 * RNGBenchmark.measureXorR          avgt    3   1346017624.333 ±  151221919.876  ns/op
067 *
068 * RNGBenchmark.measureLight                 avgt    3   1271.746 ±  155.345  ms/op
069 * RNGBenchmark.measureLightInt              avgt    3   1271.499 ±   64.098  ms/op
070 * RNGBenchmark.measureLightIntR             avgt    3   1426.202 ±  132.951  ms/op
071 * RNGBenchmark.measureLightR                avgt    3   1271.037 ±   69.143  ms/op
072 * RNGBenchmark.measureMT                    avgt    3  42625.239 ±  969.951  ms/op
073 * RNGBenchmark.measureMTInt                 avgt    3  22143.479 ± 2771.177  ms/op
074 * RNGBenchmark.measureMTIntR                avgt    3  22322.939 ± 1853.463  ms/op
075 * RNGBenchmark.measureMTR                   avgt    3  43003.067 ± 8246.183  ms/op
076 * RNGBenchmark.measurePermuted              avgt    3   1650.486 ±   24.306  ms/op
077 * RNGBenchmark.measurePermutedInt           avgt    3   1746.945 ±  102.116  ms/op
078 * RNGBenchmark.measurePermutedIntR          avgt    3   1746.471 ±  133.611  ms/op
079 * RNGBenchmark.measurePermutedR             avgt    3   1662.623 ±  154.331  ms/op
080 * RNGBenchmark.measureRandom                avgt    3  22601.739 ±  277.755  ms/op
081 * RNGBenchmark.measureRandomInt             avgt    3  12685.072 ±   75.535  ms/op
082 * RNGBenchmark.measureXor                   avgt    3   1382.533 ±   50.650  ms/op
083 * RNGBenchmark.measureXorInt                avgt    3   1288.620 ±   74.813  ms/op
084 * RNGBenchmark.measureXorIntR               avgt    3   1229.695 ±   85.585  ms/op
085 * RNGBenchmark.measureXorR                  avgt    3   1358.552 ±   78.095  ms/op
086 * RNGBenchmark.measureThreadLocalRandom     avgt    3   1518.164 ±   63.002  ms/op
087 * RNGBenchmark.measureThreadLocalRandomInt  avgt    3   1387.081 ±   26.544  ms/op
088 *
089 * Benchmark                                 Mode  Cnt       Score      Error  Units
090 * RNGBenchmark.measureChaosR                avgt    3    1991.710 ±   25.528  ms/op
091 * RNGBenchmark.measureChaosRInt             avgt    3    2013.044 ±   45.370  ms/op
092 * RNGBenchmark.measureLight                 avgt    3    1270.195 ±   25.362  ms/op
093 * RNGBenchmark.measureLightInt              avgt    3    1268.299 ±   51.405  ms/op
094 * RNGBenchmark.measureLightIntR             avgt    3    1430.807 ±   33.260  ms/op
095 * RNGBenchmark.measureLightR                avgt    3    1275.100 ±  108.047  ms/op
096 * RNGBenchmark.measurePermuted              avgt    3    1646.291 ±   15.124  ms/op
097 * RNGBenchmark.measurePermutedInt           avgt    3    1747.967 ±   75.774  ms/op
098 * RNGBenchmark.measurePermutedIntR          avgt    3    1749.495 ±   61.203  ms/op
099 * RNGBenchmark.measurePermutedR             avgt    3    1662.216 ±   30.412  ms/op
100 * RNGBenchmark.measureSecureRandom          avgt    3  162726.751 ± 8173.061  ms/op
101 * RNGBenchmark.measureSecureRandomInt       avgt    3   81390.982 ±  471.706  ms/op
102 * RNGBenchmark.measureThreadLocalRandom     avgt    3    1463.199 ±  164.716  ms/op
103 * RNGBenchmark.measureThreadLocalRandomInt  avgt    3    1395.997 ±  186.706  ms/op
104 * RNGBenchmark.measureXor                   avgt    3    1389.147 ±  128.362  ms/op
105 * RNGBenchmark.measureXorInt                avgt    3    1286.873 ±  152.577  ms/op
106 * RNGBenchmark.measureXorIntR               avgt    3    1228.443 ±  280.454  ms/op
107 * RNGBenchmark.measureXorR                  avgt    3    1355.535 ±   74.150  ms/op
108 *
109 * Benchmark                         Mode  Cnt     Score     Error  Units
110 * RNGBenchmark.measureLight         avgt    3  1251.677 ± 138.161  ms/op
111 * RNGBenchmark.measureLightInt      avgt    3  1245.465 ±  30.920  ms/op
112 * RNGBenchmark.measureLightIntR     avgt    3  1405.867 ±  71.977  ms/op
113 * RNGBenchmark.measureLightR        avgt    3  1249.536 ±  17.589  ms/op
114 * RNGBenchmark.measurePermuted      avgt    3  1618.965 ± 191.034  ms/op
115 * RNGBenchmark.measurePermutedInt   avgt    3  1719.651 ±  81.618  ms/op
116 * RNGBenchmark.measurePermutedIntR  avgt    3  1724.723 ± 361.353  ms/op
117 * RNGBenchmark.measurePermutedR     avgt    3  1631.643 ± 224.490  ms/op
118 * RNGBenchmark.measureXoRo          avgt    3  1215.819 ± 123.754  ms/op
119 * RNGBenchmark.measureXoRoInt       avgt    3  1377.244 ±  82.096  ms/op
120 * RNGBenchmark.measureXoRoIntR      avgt    3  1446.973 ±  61.399  ms/op
121 * RNGBenchmark.measureXoRoR         avgt    3  1274.790 ± 114.618  ms/op
122 * RNGBenchmark.measureXor           avgt    3  1362.249 ±  24.538  ms/op
123 * RNGBenchmark.measureXorInt        avgt    3  1263.790 ±  41.724  ms/op
124 * RNGBenchmark.measureXorIntR       avgt    3  1210.991 ± 105.103  ms/op
125 * RNGBenchmark.measureXorR          avgt    3  1331.630 ±  77.693  ms/op
126 *
127 * Benchmark                               Mode  Cnt     Score     Error  Units
128 * RNGBenchmark.measureLight               avgt    3  1269.143 ±  85.918  ms/op
129 * RNGBenchmark.measureLightBetweenHastyR  avgt    3  1617.676 ± 316.244  ms/op
130 * RNGBenchmark.measureLightBetweenR       avgt    3  2920.878 ± 169.583  ms/op
131 * RNGBenchmark.measureLightInt            avgt    3  1267.969 ±  47.884  ms/op
132 * RNGBenchmark.measureLightIntR           avgt    3  1425.842 ±  89.710  ms/op
133 * RNGBenchmark.measureLightR              avgt    3  1270.877 ±  62.054  ms/op
134 * RNGBenchmark.measurePermuted            avgt    3  1647.609 ±  22.511  ms/op
135 * RNGBenchmark.measurePermutedInt         avgt    3  1749.033 ± 147.920  ms/op
136 * RNGBenchmark.measurePermutedIntR        avgt    3  1744.506 ±  77.704  ms/op
137 * RNGBenchmark.measurePermutedR           avgt    3  1679.043 ± 733.835  ms/op
138 * RNGBenchmark.measureXoRo                avgt    3  1234.455 ± 112.165  ms/op
139 * RNGBenchmark.measureXoRoInt             avgt    3  1400.915 ±  12.242  ms/op
140 * RNGBenchmark.measureXoRoIntR            avgt    3  1471.615 ±  12.909  ms/op
141 * RNGBenchmark.measureXoRoR               avgt    3  1298.212 ±  13.077  ms/op
142 * RNGBenchmark.measureXor                 avgt    3  1392.523 ±  74.491  ms/op
143 * RNGBenchmark.measureXorInt              avgt    3  1286.622 ±  17.861  ms/op
144 * RNGBenchmark.measureXorIntR             avgt    3  1229.620 ±  50.388  ms/op
145 * RNGBenchmark.measureXorR                avgt    3  1356.388 ±  61.536  ms/op
146 *
147 * Benchmark                               Mode  Cnt     Score     Error  Units
148 * RNGBenchmark.measureGDX                 avgt    3  1387.068 ±  39.887  ms/op
149 * RNGBenchmark.measureGDXInt              avgt    3  1340.047 ±  12.284  ms/op
150 * RNGBenchmark.measureIsaac               avgt    3  5895.743 ± 673.415  ms/op
151 * RNGBenchmark.measureIsaacInt            avgt    3  5910.345 ± 372.230  ms/op
152 * RNGBenchmark.measureIsaacR              avgt    3  6063.574 ± 276.814  ms/op
153 * RNGBenchmark.measureLight               avgt    3  1265.901 ± 145.178  ms/op
154 * RNGBenchmark.measureLightBetweenHastyR  avgt    3  1605.859 ±  36.246  ms/op
155 * RNGBenchmark.measureLightBetweenR       avgt    3  2986.241 ± 140.256  ms/op
156 * RNGBenchmark.measureLightInt            avgt    3  1277.823 ± 199.616  ms/op
157 * RNGBenchmark.measureLightIntR           avgt    3  1424.500 ±  31.110  ms/op
158 * RNGBenchmark.measureLightR              avgt    3  1271.564 ±  73.357  ms/op\
159 * RNGBenchmark.measurePermuted            avgt    3  1647.924 ±  52.709  ms/op
160 * RNGBenchmark.measurePermutedInt         avgt    3  1747.788 ±  47.732  ms/op
161 * RNGBenchmark.measurePermutedIntR        avgt    3  1749.924 ±  85.835  ms/op
162 * RNGBenchmark.measurePermutedR           avgt    3  1649.223 ±  28.546  ms/op
163 * RNGBenchmark.measureXoRo                avgt    3  1228.254 ±  16.915  ms/op
164 * RNGBenchmark.measureXoRoInt             avgt    3  1395.978 ±  80.767  ms/op
165 * RNGBenchmark.measureXoRoIntR            avgt    3  1475.439 ±  30.060  ms/op
166 * RNGBenchmark.measureXoRoR               avgt    3  1297.531 ±  32.635  ms/op
167 * RNGBenchmark.measureXor                 avgt    3  1386.555 ±  41.859  ms/op
168 * RNGBenchmark.measureXorInt              avgt    3  1286.369 ±  45.825  ms/op
169 * RNGBenchmark.measureXorIntR             avgt    3  1227.971 ±  23.930  ms/op
170 * RNGBenchmark.measureXorR                avgt    3  1354.662 ±  83.443  ms/op
171 *
172 * Benchmark                        Mode  Cnt     Score     Error  Units
173 * RNGBenchmark.measureGDX          avgt    3  1335.200 ±  55.131  ms/op
174 * RNGBenchmark.measureGDXInt       avgt    3  1284.587 ± 115.753  ms/op
175 * RNGBenchmark.measureLight        avgt    3  1220.308 ± 152.938  ms/op
176 * RNGBenchmark.measureLightInt     avgt    3  1215.762 ±  88.660  ms/op
177 * RNGBenchmark.measureLightIntR    avgt    3  1365.114 ±  99.494  ms/op
178 * RNGBenchmark.measureLightR       avgt    3  1221.436 ±  69.999  ms/op
179 * RNGBenchmark.measurePermuted     avgt    3  1599.886 ± 628.296  ms/op
180 * RNGBenchmark.measurePermutedInt  avgt    3  1672.186 ± 110.668  ms/op
181 * RNGBenchmark.measureThunder      avgt    3   761.156 ±  26.884  ms/op
182 * RNGBenchmark.measureThunderInt   avgt    3   846.351 ± 315.138  ms/op
183 * RNGBenchmark.measureThunderIntR  avgt    3   918.034 ± 223.494  ms/op
184 * RNGBenchmark.measureThunderR     avgt    3   838.914 ±  62.472  ms/op
185 * RNGBenchmark.measureXoRo         avgt    3  1179.352 ±  44.233  ms/op
186 * RNGBenchmark.measureXoRoInt      avgt    3  1342.901 ±  21.042  ms/op
187 * RNGBenchmark.measureXoRoIntR     avgt    3  1415.585 ±  71.514  ms/op
188 * RNGBenchmark.measureXoRoR        avgt    3  1245.577 ±  39.306  ms/op
189 *
190 * Benchmark                        Mode  Cnt     Score     Error  Units
191 * RNGBenchmark.measureGDX          avgt    3  1349.265 ±  58.767  ms/op
192 * RNGBenchmark.measureGDXInt       avgt    3  1313.436 ± 275.429  ms/op
193 * RNGBenchmark.measureLight        avgt    3  1268.311 ±  54.113  ms/op
194 * RNGBenchmark.measureLightInt     avgt    3  1268.068 ±  67.096  ms/op
195 * RNGBenchmark.measureLightIntR    avgt    3  1430.136 ±  64.875  ms/op
196 * RNGBenchmark.measureLightR       avgt    3  1272.734 ±  79.132  ms/op
197 * RNGBenchmark.measurePermuted     avgt    3  1649.275 ±  55.005  ms/op
198 * RNGBenchmark.measurePermutedInt  avgt    3  1773.061 ± 973.661  ms/op
199 * RNGBenchmark.measureThunder      avgt    3   714.949 ±  41.154  ms/op
200 * RNGBenchmark.measureThunderInt   avgt    3   793.242 ±  12.410  ms/op
201 * RNGBenchmark.measureThunderIntR  avgt    3   793.398 ±  41.674  ms/op
202 * RNGBenchmark.measureThunderR     avgt    3   715.476 ±  84.131  ms/op
203 * RNGBenchmark.measureXoRo         avgt    3  1233.067 ±  17.727  ms/op
204 * RNGBenchmark.measureXoRoInt      avgt    3  1407.854 ± 111.257  ms/op
205 * RNGBenchmark.measureXoRoIntR     avgt    3  1470.919 ±  57.782  ms/op
206 * RNGBenchmark.measureXoRoR        avgt    3  1303.842 ± 116.414  ms/op
207 *
208 * Benchmark                        Mode  Cnt     Score     Error  Units
209 * RNGBenchmark.measureGDX          avgt    3  1330.069 ±  82.401  ms/op
210 * RNGBenchmark.measureGDXInt       avgt    3  1272.507 ± 103.801  ms/op
211 * RNGBenchmark.measureLight        avgt    3  1233.945 ± 653.550  ms/op
212 * RNGBenchmark.measureLightInt     avgt    3  1211.301 ±  79.526  ms/op
213 * RNGBenchmark.measureLightIntR    avgt    3  1392.179 ± 552.502  ms/op
214 * RNGBenchmark.measureLightR       avgt    3  1207.975 ± 107.328  ms/op
215 * RNGBenchmark.measureThunder      avgt    3   848.403 ±  55.360  ms/op
216 * RNGBenchmark.measureThunderInt   avgt    3   920.933 ±  55.772  ms/op
217 * RNGBenchmark.measureThunderIntR  avgt    3  1074.927 ± 119.307  ms/op
218 * RNGBenchmark.measureThunderR     avgt    3   916.797 ±  58.557  ms/op
219 * RNGBenchmark.measureXoRo         avgt    3  1182.115 ± 146.899  ms/op
220 * RNGBenchmark.measureXoRoInt      avgt    3  1382.232 ±  68.132  ms/op
221 * RNGBenchmark.measureXoRoIntR     avgt    3  1458.964 ±  10.307  ms/op
222 * RNGBenchmark.measureXoRoR        avgt    3  1249.812 ± 450.441  ms/op
223 *
224 * Benchmark                        Mode  Cnt     Score     Error  Units
225 * RNGBenchmark.measureGDX          avgt    5  1443.180 ±  21.341  ms/op
226 * RNGBenchmark.measureGDXInt       avgt    5  1389.316 ±  28.694  ms/op
227 * RNGBenchmark.measureLight        avgt    5  1322.170 ±  17.512  ms/op
228 * RNGBenchmark.measureLightInt     avgt    5  1321.347 ±   8.074  ms/op
229 * RNGBenchmark.measureLightIntR    avgt    5  1497.184 ±  63.809  ms/op
230 * RNGBenchmark.measureLightR       avgt    5  1319.403 ±  16.077  ms/op
231 * RNGBenchmark.measurePermuted     avgt    5  1678.603 ±  19.053  ms/op
232 * RNGBenchmark.measurePermutedInt  avgt    5  1759.054 ± 253.032  ms/op
233 * RNGBenchmark.measurePint         avgt    5  4433.747 ±  12.294  ms/op
234 * RNGBenchmark.measurePintInt      avgt    5  1788.244 ±  14.589  ms/op
235 * RNGBenchmark.measurePintIntR     avgt    5  1791.904 ±  36.237  ms/op
236 * RNGBenchmark.measurePintR        avgt    5  4581.224 ±  77.325  ms/op
237 * RNGBenchmark.measureThunder      avgt    5   914.464 ±   6.066  ms/op
238 * RNGBenchmark.measureThunderInt   avgt    5  1075.635 ±  19.411  ms/op
239 * RNGBenchmark.measureThunderIntR  avgt    5  1156.366 ±  10.684  ms/op
240 * RNGBenchmark.measureThunderR     avgt    5   992.199 ±   5.749  ms/op
241 * RNGBenchmark.measureXoRo         avgt    5  1353.115 ±  14.770  ms/op
242 * RNGBenchmark.measureXoRoInt      avgt    5  1440.937 ±  26.151  ms/op
243 * RNGBenchmark.measureXoRoIntR     avgt    5  1551.285 ±  45.324  ms/op
244 * RNGBenchmark.measureXoRoR        avgt    5  1415.288 ±  28.783  ms/op
245 */
246public class RNGBenchmark {
247
248    private static long seed = 9000;
249    private static int iseed = 9000;
250
251    public long doPint()
252    {
253        PintRNG rng = new PintRNG(seed);
254
255        for (int i = 0; i < 1000000000; i++) {
256            seed += rng.nextLong();
257        }
258        return seed;
259    }
260
261    @Benchmark
262    @BenchmarkMode(Mode.AverageTime)
263    @OutputTimeUnit(TimeUnit.MILLISECONDS)
264    public void measurePint() throws InterruptedException {
265        seed = 9000;
266        doPint();
267    }
268
269    public long doPintInt()
270    {
271        PintRNG rng = new PintRNG(iseed);
272
273        for (int i = 0; i < 1000000000; i++) {
274            iseed += rng.nextInt();
275        }
276        return iseed;
277    }
278
279    @Benchmark
280    @BenchmarkMode(Mode.AverageTime)
281    @OutputTimeUnit(TimeUnit.MILLISECONDS)
282    public void measurePintInt() throws InterruptedException {
283        iseed = 9000;
284        doPintInt();
285    }
286    public long doPintR()
287    {
288        RNG rng = new RNG(new PintRNG(seed));
289
290        for (int i = 0; i < 1000000000; i++) {
291            seed += rng.nextLong();
292        }
293        return seed;
294    }
295
296    @Benchmark
297    @BenchmarkMode(Mode.AverageTime)
298    @OutputTimeUnit(TimeUnit.MILLISECONDS)
299    public void measurePintR() throws InterruptedException {
300        seed = 9000;
301        doPintR();
302    }
303
304    public long doPintIntR()
305    {
306        RNG rng = new RNG(new PintRNG(iseed));
307
308        for (int i = 0; i < 1000000000; i++) {
309            iseed += rng.nextInt();
310        }
311        return iseed;
312    }
313
314    @Benchmark
315    @BenchmarkMode(Mode.AverageTime)
316    @OutputTimeUnit(TimeUnit.MILLISECONDS)
317    public void measurePintIntR() throws InterruptedException {
318        iseed = 9000;
319        doPintIntR();
320    }
321/*
322    public long doThunder()
323    {
324        ThunderRNG rng = new ThunderRNG(seed);
325
326        for (int i = 0; i < 1000000000; i++) {
327            seed += rng.nextLong();
328        }
329        return seed;
330    }
331
332    @Benchmark
333    @BenchmarkMode(Mode.AverageTime)
334    @OutputTimeUnit(TimeUnit.MILLISECONDS)
335    public void measureThunder() throws InterruptedException {
336        seed = 9000;
337        doThunder();
338    }
339
340    public long doThunderInt()
341    {
342        ThunderRNG rng = new ThunderRNG(iseed);
343
344        for (int i = 0; i < 1000000000; i++) {
345            iseed += rng.nextInt();
346        }
347        return iseed;
348    }
349
350    @Benchmark
351    @BenchmarkMode(Mode.AverageTime)
352    @OutputTimeUnit(TimeUnit.MILLISECONDS)
353    public void measureThunderInt() throws InterruptedException {
354        iseed = 9000;
355        doThunderInt();
356    }
357    public long doThunderR()
358    {
359        RNG rng = new RNG(new ThunderRNG(seed));
360
361        for (int i = 0; i < 1000000000; i++) {
362            seed += rng.nextLong();
363        }
364        return seed;
365    }
366
367    @Benchmark
368    @BenchmarkMode(Mode.AverageTime)
369    @OutputTimeUnit(TimeUnit.MILLISECONDS)
370    public void measureThunderR() throws InterruptedException {
371        seed = 9000;
372        doThunderR();
373    }
374
375    public long doThunderIntR()
376    {
377        RNG rng = new RNG(new ThunderRNG(iseed));
378
379        for (int i = 0; i < 1000000000; i++) {
380            iseed += rng.nextInt();
381        }
382        return iseed;
383    }
384
385    @Benchmark
386    @BenchmarkMode(Mode.AverageTime)
387    @OutputTimeUnit(TimeUnit.MILLISECONDS)
388    public void measureThunderIntR() throws InterruptedException {
389        iseed = 9000;
390        doThunderIntR();
391    }
392
393    public long doXoRo()
394    {
395        XoRoRNG rng = new XoRoRNG(seed);
396        for (int i = 0; i < 1000000000; i++) {
397            seed += rng.nextLong();
398        }
399        return seed;
400    }
401
402    @Benchmark
403    @BenchmarkMode(Mode.AverageTime)
404    @OutputTimeUnit(TimeUnit.MILLISECONDS)
405    public void measureXoRo() throws InterruptedException {
406        seed = 9000;
407        doXoRo();
408    }
409
410    public long doXoRoInt()
411    {
412        XoRoRNG rng = new XoRoRNG(iseed);
413        for (int i = 0; i < 1000000000; i++) {
414            iseed += rng.nextInt();
415        }
416        return iseed;
417    }
418    @Benchmark
419    @BenchmarkMode(Mode.AverageTime)
420    @OutputTimeUnit(TimeUnit.MILLISECONDS)
421    public void measureXoRoInt() throws InterruptedException {
422        iseed = 9000;
423        doXoRoInt();
424    }
425
426    public long doXoRoR()
427    {
428        RNG rng = new RNG(new XoRoRNG(seed));
429        for (int i = 0; i < 1000000000; i++) {
430            seed += rng.nextLong();
431        }
432        return seed;
433    }
434
435    @Benchmark
436    @BenchmarkMode(Mode.AverageTime)
437    @OutputTimeUnit(TimeUnit.MILLISECONDS)
438    public void measureXoRoR() throws InterruptedException {
439        seed = 9000;
440        doXoRoR();
441    }
442
443    public long doXoRoIntR()
444    {
445        RNG rng = new RNG(new XoRoRNG(iseed));
446        for (int i = 0; i < 1000000000; i++) {
447            iseed += rng.nextInt();
448        }
449        return iseed;
450    }
451    @Benchmark
452    @BenchmarkMode(Mode.AverageTime)
453    @OutputTimeUnit(TimeUnit.MILLISECONDS)
454    public void measureXoRoIntR() throws InterruptedException {
455        iseed = 9000;
456        doXoRoIntR();
457    }
458*/
459    public long doLight()
460    {
461        LightRNG rng = new LightRNG(seed);
462
463        for (int i = 0; i < 1000000000; i++) {
464            seed += rng.nextLong();
465        }
466        return seed;
467    }
468
469    @Benchmark
470    @BenchmarkMode(Mode.AverageTime)
471    @OutputTimeUnit(TimeUnit.MILLISECONDS)
472    public void measureLight() throws InterruptedException {
473        seed = 9000;
474        doLight();
475    }
476
477    public long doLightInt()
478    {
479        LightRNG rng = new LightRNG(iseed);
480
481        for (int i = 0; i < 1000000000; i++) {
482            iseed += rng.nextInt();
483        }
484        return iseed;
485    }
486
487    @Benchmark
488    @BenchmarkMode(Mode.AverageTime)
489    @OutputTimeUnit(TimeUnit.MILLISECONDS)
490    public void measureLightInt() throws InterruptedException {
491        iseed = 9000;
492        doLightInt();
493    }
494    public long doLightR()
495    {
496        RNG rng = new RNG(new LightRNG(seed));
497
498        for (int i = 0; i < 1000000000; i++) {
499            seed += rng.nextLong();
500        }
501        return seed;
502    }
503
504    @Benchmark
505    @BenchmarkMode(Mode.AverageTime)
506    @OutputTimeUnit(TimeUnit.MILLISECONDS)
507    public void measureLightR() throws InterruptedException {
508        seed = 9000;
509        doLightR();
510    }
511
512    public long doLightIntR()
513    {
514        RNG rng = new RNG(new LightRNG(iseed));
515
516        for (int i = 0; i < 1000000000; i++) {
517            iseed += rng.nextInt();
518        }
519        return iseed;
520    }
521
522    @Benchmark
523    @BenchmarkMode(Mode.AverageTime)
524    @OutputTimeUnit(TimeUnit.MILLISECONDS)
525    public void measureLightIntR() throws InterruptedException {
526        iseed = 9000;
527        doLightIntR();
528    }
529
530    /*
531    public long doLightBetweenR()
532    {
533        RNG rng = new RNG(new LightRNG(iseed));
534
535        for (int i = 0; i < 1000000000; i++) {
536            iseed += rng.nextInt(1000);
537        }
538        return iseed;
539    }
540
541    @Benchmark
542    @BenchmarkMode(Mode.AverageTime)
543    @OutputTimeUnit(TimeUnit.MILLISECONDS)
544    public void measureLightBetweenR() throws InterruptedException {
545        iseed = 9000;
546        System.out.println(doLightBetweenR());
547    }
548    public long doLightBetweenHastyR()
549    {
550        RNG rng = new RNG(new LightRNG(iseed));
551
552        for (int i = 0; i < 1000000000; i++) {
553            iseed += rng.nextIntHasty(1000);
554        }
555        return iseed;
556    }
557
558    @Benchmark
559    @BenchmarkMode(Mode.AverageTime)
560    @OutputTimeUnit(TimeUnit.MILLISECONDS)
561    public void measureLightBetweenHastyR() throws InterruptedException {
562        iseed = 9000;
563        System.out.println(doLightBetweenHastyR());
564    }
565    */
566
567
568    public long doPermuted()
569    {
570        PermutedRNG rng = new PermutedRNG(seed);
571        for (int i = 0; i < 1000000000; i++) {
572            seed += rng.nextLong();
573        }
574        return seed;
575    }
576
577    @Benchmark
578    @BenchmarkMode(Mode.AverageTime)
579    @OutputTimeUnit(TimeUnit.MILLISECONDS)
580    public void measurePermuted() throws InterruptedException {
581        seed = 9000;
582        doPermuted();
583    }
584
585    public long doPermutedInt()
586    {
587        PermutedRNG rng = new PermutedRNG(iseed);
588        for (int i = 0; i < 1000000000; i++) {
589            iseed += rng.nextInt();
590        }
591        return iseed;
592    }
593    @Benchmark
594    @BenchmarkMode(Mode.AverageTime)
595    @OutputTimeUnit(TimeUnit.MILLISECONDS)
596    public void measurePermutedInt() throws InterruptedException {
597        iseed = 9000;
598        doPermutedInt();
599    }
600
601    public long doPermutedR()
602    {
603        RNG rng = new RNG(new PermutedRNG(seed));
604        for (int i = 0; i < 1000000000; i++) {
605            seed += rng.nextLong();
606        }
607        return seed;
608    }
609
610    @Benchmark
611    @BenchmarkMode(Mode.AverageTime)
612    @OutputTimeUnit(TimeUnit.MILLISECONDS)
613    public void measurePermutedR() throws InterruptedException {
614        seed = 9000;
615        doPermutedR();
616    }
617
618    public long doPermutedIntR()
619    {
620        RNG rng = new RNG(new PermutedRNG(iseed));
621        for (int i = 0; i < 1000000000; i++) {
622            iseed += rng.nextInt();
623        }
624        return iseed;
625    }
626    @Benchmark
627    @BenchmarkMode(Mode.AverageTime)
628    @OutputTimeUnit(TimeUnit.MILLISECONDS)
629    public void measurePermutedIntR() throws InterruptedException {
630        iseed = 9000;
631        doPermutedIntR();
632    }
633
634
635    public long doLFSR()
636    {
637        LFSR rng = new LFSR(seed);
638
639        for (int i = 0; i < 1000000000; i++) {
640            seed += rng.nextLong();
641        }
642        return seed;
643    }
644
645    @Benchmark
646    @BenchmarkMode(Mode.AverageTime)
647    @OutputTimeUnit(TimeUnit.MILLISECONDS)
648    public void measureLFSR() throws InterruptedException {
649        seed = 9000;
650        doLFSR();
651    }
652
653    public long doLFSRInt()
654    {
655        LFSR rng = new LFSR(iseed);
656
657        for (int i = 0; i < 1000000000; i++) {
658            iseed += rng.nextInt();
659        }
660        return iseed;
661    }
662
663    @Benchmark
664    @BenchmarkMode(Mode.AverageTime)
665    @OutputTimeUnit(TimeUnit.MILLISECONDS)
666    public void measureLFSRInt() throws InterruptedException {
667        iseed = 9000;
668        doLFSRInt();
669    }
670    public long doLFSRR()
671    {
672        RNG rng = new RNG(new LFSR(seed));
673
674        for (int i = 0; i < 1000000000; i++) {
675            seed += rng.nextLong();
676        }
677        return seed;
678    }
679
680    @Benchmark
681    @BenchmarkMode(Mode.AverageTime)
682    @OutputTimeUnit(TimeUnit.MILLISECONDS)
683    public void measureLFSRR() throws InterruptedException {
684        seed = 9000;
685        doLFSRR();
686    }
687
688    public long doLFSRIntR()
689    {
690        RNG rng = new RNG(new LFSR(iseed));
691
692        for (int i = 0; i < 1000000000; i++) {
693            iseed += rng.nextInt();
694        }
695        return iseed;
696    }
697
698    @Benchmark
699    @BenchmarkMode(Mode.AverageTime)
700    @OutputTimeUnit(TimeUnit.MILLISECONDS)
701    public void measureLFSRIntR() throws InterruptedException {
702        iseed = 9000;
703        doLFSRIntR();
704    }
705
706    /*
707    public long doXor()
708    {
709        XorRNG rng = new XorRNG(seed);
710        for (int i = 0; i < 1000000000; i++) {
711            seed += rng.nextLong();
712        }
713        return seed;
714    }
715
716    @Benchmark
717    @BenchmarkMode(Mode.AverageTime)
718    @OutputTimeUnit(TimeUnit.MILLISECONDS)
719    public void measureXor() throws InterruptedException {
720        seed = 9000;
721        doXor();
722    }
723
724    public long doXorInt()
725    {
726        XorRNG rng = new XorRNG(iseed);
727        for (int i = 0; i < 1000000000; i++) {
728            iseed += rng.nextInt();
729        }
730        return iseed;
731    }
732    @Benchmark
733    @BenchmarkMode(Mode.AverageTime)
734    @OutputTimeUnit(TimeUnit.MILLISECONDS)
735    public void measureXorInt() throws InterruptedException {
736        iseed = 9000;
737        doXorInt();
738    }
739
740    public long doXorR()
741    {
742        RNG rng = new RNG(new XorRNG(seed));
743        for (int i = 0; i < 1000000000; i++) {
744            seed += rng.nextLong();
745        }
746        return seed;
747    }
748
749    @Benchmark
750    @BenchmarkMode(Mode.AverageTime)
751    @OutputTimeUnit(TimeUnit.MILLISECONDS)
752    public void measureXorR() throws InterruptedException {
753        seed = 9000;
754        doXorR();
755    }
756
757    public long doXorIntR()
758    {
759        RNG rng = new RNG(new XorRNG(iseed));
760        for (int i = 0; i < 1000000000; i++) {
761            iseed += rng.nextInt();
762        }
763        return iseed;
764    }
765    @Benchmark
766    @BenchmarkMode(Mode.AverageTime)
767    @OutputTimeUnit(TimeUnit.MILLISECONDS)
768    public void measureXorIntR() throws InterruptedException {
769        iseed = 9000;
770        doXorIntR();
771    }
772
773    public long doChaosR()
774    {
775        RNG rng = new RNG(new ChaosRNG());
776        //rng.setSeed(seed);
777
778        for (int i = 0; i < 1000000000; i++) {
779            seed += rng.nextLong();
780        }
781        return seed;
782    }
783
784    //@Benchmark
785    @BenchmarkMode(Mode.AverageTime)
786    @OutputTimeUnit(TimeUnit.MILLISECONDS)
787    public void measureChaosR() throws InterruptedException {
788        seed = 9000;
789        doChaosR();
790    }
791
792    public long doChaosRInt()
793    {
794        RNG rng = new RNG(new ChaosRNG());
795        //rng.setSeed(iseed);
796
797        for (int i = 0; i < 1000000000; i++) {
798            iseed += rng.nextInt();
799        }
800        return iseed;
801    }
802
803    //@Benchmark
804    @BenchmarkMode(Mode.AverageTime)
805    @OutputTimeUnit(TimeUnit.MILLISECONDS)
806    public void measureChaosRInt() throws InterruptedException {
807        iseed = 9000;
808        doChaosRInt();
809    }
810    public long doThreadLocalRandom()
811    {
812        ThreadLocalRandom rng = ThreadLocalRandom.current();
813        //rng.setSeed(seed);
814
815        for (int i = 0; i < 1000000000; i++) {
816            seed += rng.nextLong();
817        }
818        return seed;
819    }
820
821    //@Benchmark
822    @BenchmarkMode(Mode.AverageTime)
823    @OutputTimeUnit(TimeUnit.MILLISECONDS)
824    public void measureThreadLocalRandom() throws InterruptedException {
825        seed = 9000;
826        doThreadLocalRandom();
827    }
828
829    public long doThreadLocalRandomInt()
830    {
831        ThreadLocalRandom rng = ThreadLocalRandom.current();
832        //rng.setSeed(iseed);
833
834        for (int i = 0; i < 1000000000; i++) {
835            iseed += rng.nextInt();
836        }
837        return iseed;
838    }
839
840    //@Benchmark
841    @BenchmarkMode(Mode.AverageTime)
842    @OutputTimeUnit(TimeUnit.MILLISECONDS)
843    public void measureThreadLocalRandomInt() throws InterruptedException {
844        iseed = 9000;
845        doThreadLocalRandomInt();
846    }
847    public long doRandom()
848    {
849        Random rng = new Random(seed);
850
851        for (int i = 0; i < 1000000000; i++) {
852            seed += rng.nextLong();
853        }
854        return seed;
855    }
856
857    //@Benchmark
858    @BenchmarkMode(Mode.AverageTime)
859    @OutputTimeUnit(TimeUnit.MILLISECONDS)
860    public void measureRandom() throws InterruptedException {
861        seed = 9000;
862        doRandom();
863    }
864
865    public long doRandomInt()
866    {
867        Random rng = new Random(iseed);
868
869        for (int i = 0; i < 1000000000; i++) {
870            iseed += rng.nextInt();
871        }
872        return iseed;
873    }
874
875    //@Benchmark
876    @BenchmarkMode(Mode.AverageTime)
877    @OutputTimeUnit(TimeUnit.MILLISECONDS)
878    public void measureRandomInt() throws InterruptedException {
879        iseed = 9000;
880        doRandomInt();
881    }
882
883
884    public long doGDX()
885    {
886        RandomXS128 rng = new RandomXS128(seed);
887
888        for (int i = 0; i < 1000000000; i++) {
889            seed += rng.nextLong();
890        }
891        return seed;
892    }
893
894    @Benchmark
895    @BenchmarkMode(Mode.AverageTime)
896    @OutputTimeUnit(TimeUnit.MILLISECONDS)
897    public void measureGDX() throws InterruptedException {
898        seed = 9000;
899        doGDX();
900    }
901
902    public long doGDXInt()
903    {
904        RandomXS128 rng = new RandomXS128(iseed);
905
906        for (int i = 0; i < 1000000000; i++) {
907            iseed += rng.nextInt();
908        }
909        return iseed;
910    }
911
912    @Benchmark
913    @BenchmarkMode(Mode.AverageTime)
914    @OutputTimeUnit(TimeUnit.MILLISECONDS)
915    public void measureGDXInt() throws InterruptedException {
916        iseed = 9000;
917        doGDXInt();
918    }
919    /*
920    public long doIsaac()
921    {
922        IsaacRNG rng = new IsaacRNG(seed);
923
924        for (int i = 0; i < 1000000000; i++) {
925            seed += rng.nextLong();
926        }
927        return seed;
928    }
929
930    @Benchmark
931    @BenchmarkMode(Mode.AverageTime)
932    @OutputTimeUnit(TimeUnit.MILLISECONDS)
933    public void measureIsaac() throws InterruptedException {
934        seed = 9000;
935        doIsaac();
936    }
937
938    public long doIsaacInt()
939    {
940        IsaacRNG rng = new IsaacRNG(iseed);
941
942        for (int i = 0; i < 1000000000; i++) {
943            iseed += rng.next(32);
944        }
945        return iseed;
946    }
947
948    @Benchmark
949    @BenchmarkMode(Mode.AverageTime)
950    @OutputTimeUnit(TimeUnit.MILLISECONDS)
951    public void measureIsaacInt() throws InterruptedException {
952        iseed = 9000;
953        doIsaacInt();
954    }
955    public long doIsaacR()
956    {
957        RNG rng = new RNG(new IsaacRNG(seed));
958
959        for (int i = 0; i < 1000000000; i++) {
960            seed += rng.nextLong();
961        }
962        return seed;
963    }
964
965    @Benchmark
966    @BenchmarkMode(Mode.AverageTime)
967    @OutputTimeUnit(TimeUnit.MILLISECONDS)
968    public void measureIsaacR() throws InterruptedException {
969        seed = 9000;
970        doIsaacR();
971    }
972
973    public long doIsaacIntR()
974    {
975        RNG rng = new RNG(new IsaacRNG(iseed));
976
977        for (int i = 0; i < 1000000000; i++) {
978            iseed += rng.nextInt();
979        }
980        return iseed;
981    }
982    */
983
984/*
985    public long doSecureRandom()
986    {
987        SecureRandom rng = new SecureRandom();
988        //rng.setSeed(seed);
989
990        for (int i = 0; i < 1000000000; i++) {
991            seed += rng.nextLong();
992        }
993        return seed;
994    }
995
996    @Benchmark
997    @BenchmarkMode(Mode.AverageTime)
998    @OutputTimeUnit(TimeUnit.MILLISECONDS)
999    public void measureSecureRandom() throws InterruptedException {
1000        seed = 9000;
1001        doSecureRandom();
1002    }
1003
1004    public long doSecureRandomInt()
1005    {
1006        SecureRandom rng = new SecureRandom();
1007        //rng.setSeed(iseed);
1008
1009        for (int i = 0; i < 1000000000; i++) {
1010            iseed += rng.nextInt();
1011        }
1012        return iseed;
1013    }
1014
1015    @Benchmark
1016    @BenchmarkMode(Mode.AverageTime)
1017    @OutputTimeUnit(TimeUnit.MILLISECONDS)
1018    public void measureSecureRandomInt() throws InterruptedException {
1019        iseed = 9000;
1020        doSecureRandomInt();
1021    }
1022*/
1023
1024
1025    /*
1026    public long doMT()
1027    {
1028        byte[] bseed = new byte[16];
1029        Arrays.fill(bseed, (byte)seed);
1030        MersenneTwister rng = new MersenneTwister(bseed);
1031        for (int i = 0; i < 1000000000; i++) {
1032            seed += rng.nextLong();
1033        }
1034        return seed;
1035    }
1036
1037    //@Benchmark
1038    @BenchmarkMode(Mode.AverageTime)
1039    @OutputTimeUnit(TimeUnit.MILLISECONDS)
1040    public void measureMT() throws InterruptedException {
1041        seed = 9000;
1042        doMT();
1043    }
1044
1045    public long doMTInt()
1046    {
1047        byte[] bseed = new byte[16];
1048        Arrays.fill(bseed, (byte)iseed);
1049        MersenneTwister rng = new MersenneTwister(bseed);
1050        for (int i = 0; i < 1000000000; i++) {
1051            iseed += rng.next(32);
1052        }
1053        return iseed;
1054    }
1055    //@Benchmark
1056    @BenchmarkMode(Mode.AverageTime)
1057    @OutputTimeUnit(TimeUnit.MILLISECONDS)
1058    public void measureMTInt() throws InterruptedException {
1059        iseed = 9000;
1060        doMTInt();
1061    }
1062
1063    public long doMTR()
1064    {
1065        byte[] bseed = new byte[16];
1066        Arrays.fill(bseed, (byte)seed);
1067        RNG rng = new RNG(new MersenneTwister(bseed));
1068        for (int i = 0; i < 1000000000; i++) {
1069            seed += rng.nextLong();
1070        }
1071        return seed;
1072    }
1073
1074    //@Benchmark
1075    @BenchmarkMode(Mode.AverageTime)
1076    @OutputTimeUnit(TimeUnit.MILLISECONDS)
1077    public void measureMTR() throws InterruptedException {
1078        seed = 9000;
1079        doMTR();
1080    }
1081
1082    public long doMTIntR()
1083    {
1084        byte[] bseed = new byte[16];
1085        Arrays.fill(bseed, (byte)iseed);
1086        RNG rng = new RNG(new MersenneTwister(bseed));
1087        for (int i = 0; i < 1000000000; i++) {
1088            iseed += rng.nextInt();
1089        }
1090        return iseed;
1091    }
1092    //@Benchmark
1093    @BenchmarkMode(Mode.AverageTime)
1094    @OutputTimeUnit(TimeUnit.MILLISECONDS)
1095    public void measureMTIntR() throws InterruptedException {
1096        iseed = 9000;
1097        doMTIntR();
1098    }
1099*/
1100
1101    /*
1102     * ============================== HOW TO RUN THIS TEST: ====================================
1103     *
1104     * You are expected to see the different run modes for the same benchmark.
1105     * Note the units are different, scores are consistent with each other.
1106     *
1107     * You can run this test:
1108     *
1109     * a) Via the command line from the squidlib-performance module's root folder:
1110     *    $ mvn clean install
1111     *    $ java -jar target/benchmarks.jar RNGBenchmark -wi 3 -i 3 -f 1
1112     *
1113     *    (we requested 5 warmup/measurement iterations, single fork)
1114     *
1115     * b) Via the Java API:
1116     *    (see the JMH homepage for possible caveats when running from IDE:
1117     *      http://openjdk.java.net/projects/code-tools/jmh/)
1118     */
1119
1120    public static void main(String[] args) throws RunnerException {
1121        Options opt = new OptionsBuilder()
1122                .include(RNGBenchmark.class.getSimpleName())
1123                .timeout(TimeValue.seconds(30))
1124                .warmupIterations(5)
1125                .measurementIterations(5)
1126                .forks(1)
1127                .build();
1128
1129        new Runner(opt).run();
1130    }
1131
1132
1133}


text:
exports.setup = function(Tests){

var Expectation = require('lib/expectation').Expectation;

Tests.describe('Expectations', function(it, setup){

	setup('beforeEach', function(){
		this.mockObj = {};
		this.mockArray = [];
		this.mockFunction = function(){};
		this.mockRegExp = /^$/;
		this.mockDate = new Date();

		this.strExp = new Expectation('abc');
		this.numExp = new Expectation(1);
		this.boolExp = new Expectation(true);
		this.objExp = new Expectation(this.mockObj);
		this.arrExp = new Expectation(this.mockArray);
		this.fnExp = new Expectation(this.mockFunction);
		this.regExp = new Expectation(this.mockRegExp);
		this.dateExp = new Expectation(this.mockDate);
	});

	it('should have a `not` object', function(expect){
		expect(this.strExp.not).toBeAnInstanceOf(Object);
	});

	it('should match toBe and not.toBe', function(expect){
		expect(this.boolExp.toBe(true)).toBeTrue();
		expect(this.numExp.toBe(1)).toBeTrue();
		expect(this.objExp.toBe(this.mockObj)).toBeTrue();

		expect(this.boolExp.not.toBe(false)).toBeTrue();
		expect(this.numExp.not.toBe(2)).toBeTrue();
		expect(this.objExp.not.toBe({})).toBeTrue();
	});

	it('should match toEqual and not.toEqual', function(expect){
		expect(this.boolExp.toEqual(true)).toBeTrue();
		expect(this.numExp.toEqual(1)).toBeTrue();
		expect(this.objExp.toEqual(this.mockObj)).toBeTrue();

		expect(this.boolExp.not.toEqual(false)).toBeTrue();
		expect(this.numExp.not.toEqual(2)).toBeTrue();
		expect(this.objExp.not.toEqual({})).toBeTrue();
	});

	it('should match toBeType', function(expect){
		expect(this.boolExp.toBeType('boolean')).toBeTrue();
		expect(this.numExp.toBeType('number')).toBeTrue();
		expect(this.strExp.toBeType('string')).toBeTrue();
		expect(this.objExp.toBeType('object')).toBeTrue();
		expect(this.arrExp.toBeType('array')).toBeTrue();
		expect(this.fnExp.toBeType('function')).toBeTrue();
		expect(this.regExp.toBeType('regexp')).toBeTrue();
		expect(this.dateExp.toBeType('date')).toBeTrue();
	});

	it('should match instanceOf for native objects', function(expect){
		expect(this.numExp.toBeAnInstanceOf(Number)).toBeTrue();
		expect(this.strExp.toBeAnInstanceOf(String)).toBeTrue();
		expect(this.boolExp.toBeAnInstanceOf(Boolean)).toBeTrue();
		expect(this.objExp.toBeAnInstanceOf(Object)).toBeTrue();
		expect(this.arrExp.toBeAnInstanceOf(Array)).toBeTrue();
		expect(this.fnExp.toBeAnInstanceOf(Function)).toBeTrue();
		expect(this.regExp.toBeAnInstanceOf(RegExp)).toBeTrue();
		expect(this.dateExp.toBeAnInstanceOf(Date)).toBeTrue();
	});

	it('should match instanceOf for classes', function(expect){
		var Klass = function(){};
		var instance = new Klass();
		expect(new Expectation(instance).toBeAnInstanceOf(Klass)).toBeTrue();
	});

});

};


text:
using System.Collections.Generic;

namespace Dragon.Context.Interfaces
{
    public interface ITreeNode<T, TData>
    {
        T Node { get; set; }
        List<ITreeNode<T, TData>> Children { get; set; }
        TData Data { get; set; }
        bool HasChildInTree(T key);
        ITreeNode<T, TData> GetChildInTree(T key);
    }
}