text:
package nom.bdezonia.zorbage.type.gaussian.int64;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.concurrent.ThreadLocalRandom;

import ch.obermuhlner.math.big.BigDecimalMath;
import nom.bdezonia.zorbage.algebra.AbsoluteValue;
import nom.bdezonia.zorbage.algebra.Conjugate;
import nom.bdezonia.zorbage.algebra.ConstructibleFromLong;
import nom.bdezonia.zorbage.algebra.EuclideanDomain;
import nom.bdezonia.zorbage.algebra.G;
import nom.bdezonia.zorbage.algebra.Norm;
import nom.bdezonia.zorbage.algebra.Random;
import nom.bdezonia.zorbage.algebra.Scale;
import nom.bdezonia.zorbage.algebra.ScaleByDouble;
import nom.bdezonia.zorbage.algebra.ScaleByDoubleAndRound;
import nom.bdezonia.zorbage.algebra.ScaleByHighPrec;
import nom.bdezonia.zorbage.algebra.ScaleByHighPrecAndRound;
import nom.bdezonia.zorbage.algebra.ScaleByOneHalf;
import nom.bdezonia.zorbage.algebra.ScaleByRational;
import nom.bdezonia.zorbage.algebra.ScaleByTwo;
import nom.bdezonia.zorbage.algebra.Tolerance;
import nom.bdezonia.zorbage.algorithm.EuclideanGcd;
import nom.bdezonia.zorbage.algorithm.EuclideanLcm;
import nom.bdezonia.zorbage.algorithm.PowerNonNegative;
import nom.bdezonia.zorbage.function.Function1;
import nom.bdezonia.zorbage.function.Function2;
import nom.bdezonia.zorbage.function.Function3;
import nom.bdezonia.zorbage.misc.BigDecimalUtils;
import nom.bdezonia.zorbage.procedure.Procedure1;
import nom.bdezonia.zorbage.procedure.Procedure2;
import nom.bdezonia.zorbage.procedure.Procedure3;
import nom.bdezonia.zorbage.procedure.Procedure4;
import nom.bdezonia.zorbage.type.complex.highprec.ComplexHighPrecisionMember;
import nom.bdezonia.zorbage.type.integer.unbounded.UnboundedIntMember;
import nom.bdezonia.zorbage.type.rational.RationalMember;
import nom.bdezonia.zorbage.type.real.highprec.HighPrecisionAlgebra;
import nom.bdezonia.zorbage.type.real.highprec.HighPrecisionMember;

/**
 *
 * @author Barry DeZonia
 *
 */
public class GaussianInt64Algebra
	implements
		EuclideanDomain<GaussianInt64Algebra, GaussianInt64Member, UnboundedIntMember>,
		Random<GaussianInt64Member>,
		Tolerance<GaussianInt64Member,GaussianInt64Member>,
		Norm<GaussianInt64Member, UnboundedIntMember>,
		Conjugate<GaussianInt64Member>,
		ScaleByOneHalf<GaussianInt64Member>,
		ScaleByTwo<GaussianInt64Member>,
		Scale<GaussianInt64Member, GaussianInt64Member>,
		ScaleByDouble<GaussianInt64Member>,
		ScaleByDoubleAndRound<GaussianInt64Member>,
		ScaleByHighPrec<GaussianInt64Member>,
		ScaleByHighPrecAndRound<GaussianInt64Member>,
		ScaleByRational<GaussianInt64Member>,
		AbsoluteValue<GaussianInt64Member, HighPrecisionMember>,
		ConstructibleFromLong<GaussianInt64Member>
{
	@Override
	public String typeDescription() {
		return "64-bit based gaussian int";
	}

	@Override
	public GaussianInt64Member construct() {
		return new GaussianInt64Member();
	}

	@Override
	public GaussianInt64Member construct(GaussianInt64Member other) {
		return new GaussianInt64Member(other);
	}

	@Override
	public GaussianInt64Member construct(String str) {
		return new GaussianInt64Member(str);
	}

	@Override
	public GaussianInt64Member construct(long... vals) {
		return new GaussianInt64Member(vals);
	}

	private final Function2<Boolean, GaussianInt64Member, GaussianInt64Member> EQ =
		new Function2<Boolean, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public Boolean call(GaussianInt64Member a, GaussianInt64Member b) {
			return a.r == b.r && a.i == b.i;
		}
	};

	@Override
	public Function2<Boolean, GaussianInt64Member, GaussianInt64Member> isEqual() {
		return EQ;
	}

	private final Function2<Boolean, GaussianInt64Member, GaussianInt64Member> NEQ =
		new Function2<Boolean, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public Boolean call(GaussianInt64Member a, GaussianInt64Member b) {
			return a.r != b.r || a.i != b.i;
		}
	};

	@Override
	public Function2<Boolean, GaussianInt64Member, GaussianInt64Member> isNotEqual() {
		return NEQ;
	}

	private final Procedure2<GaussianInt64Member, GaussianInt64Member> ASS =
			new Procedure2<GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b) {
			b.set(a);
		}
	};

	@Override
	public Procedure2<GaussianInt64Member, GaussianInt64Member> assign() {
		return ASS;
	}

	private final Procedure1<GaussianInt64Member> ZER =
			new Procedure1<GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a) {
			a.primitiveInit();
		}
	};

	@Override
	public Procedure1<GaussianInt64Member> zero() {
		return ZER;
	}

	private final Function1<Boolean, GaussianInt64Member> ISZ = new
			Function1<Boolean, GaussianInt64Member>()
	{
		@Override
		public Boolean call(GaussianInt64Member a) {
			return a.r == 0 && a.i == 0;
		}
	};

	@Override
	public Function1<Boolean, GaussianInt64Member> isZero() {
		return ISZ;
	}

	private final Procedure2<GaussianInt64Member, GaussianInt64Member> NEG =
			new Procedure2<GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b) {
			b.setR(-a.r);
			b.setI(-a.i);
		}
	};

	@Override
	public Procedure2<GaussianInt64Member, GaussianInt64Member> negate() {
		return NEG;
	}

	private final Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> ADD =
			new Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member c) {
			c.r = a.r + b.r;
			c.i = a.i + b.i;
		}
	};

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> add() {
		return ADD;
	}

	private final Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> SUB =
			new Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member c) {
			c.r = a.r - b.r;
			c.i = a.i - b.i;
		}
	};

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> subtract() {
		return SUB;
	}

	private final Procedure3<GaussianInt64Member,GaussianInt64Member,GaussianInt64Member> MUL =
			new Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member c) {
			// for safety must use tmps
			BigInteger ar = BigInteger.valueOf(a.r);
			BigInteger ai = BigInteger.valueOf(a.i);
			BigInteger br = BigInteger.valueOf(b.r);
			BigInteger bi = BigInteger.valueOf(b.i);
			BigInteger r = ar.multiply(br).subtract(ai.multiply(bi));
			BigInteger i = ai.multiply(br).add(ar.multiply(bi));
			c.setR( r.longValue() );
			c.setI( i.longValue() );
		}
	};

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> multiply() {
		return MUL;
	}

	private final Procedure3<java.lang.Integer,GaussianInt64Member,GaussianInt64Member> POWER =
			new Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(java.lang.Integer power, GaussianInt64Member a, GaussianInt64Member b) {
			PowerNonNegative.compute(G.GAUSS64, power, a, b);
		}
	};

	@Override
	public Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member> power() {
		return POWER;
	}

	private final Procedure1<GaussianInt64Member> UNITY =
			new Procedure1<GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a) {
			a.r = 1;
			a.i = 0;
		}
	};

	@Override
	public Procedure1<GaussianInt64Member> unity() {
		return UNITY;
	}

	private final Function3<Boolean, GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> WITHIN =
			new Function3<Boolean, GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public Boolean call(GaussianInt64Member tol, GaussianInt64Member a, GaussianInt64Member b) {
			if (tol.r < 0 || tol.i < 0)
				throw new IllegalArgumentException("gaussian tolerances must have nonnegative components");
			// avoid overflow/underflow conditions by using bigInts
			BigInteger dr = BigInteger.valueOf(a.r).subtract(BigInteger.valueOf(b.r)).abs();
			BigInteger di = BigInteger.valueOf(a.i).subtract(BigInteger.valueOf(b.i)).abs();
			return dr.compareTo(BigInteger.valueOf(tol.r)) <= 0 && di.compareTo(BigInteger.valueOf(tol.i)) <= 0;
		}
	};

	@Override
	public Function3<Boolean, GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> within() {
		return WITHIN;
	}

	private final Procedure1<GaussianInt64Member> RAND =
			new Procedure1<GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a) {
			// Safely generate a random long in the right range
			// I'm avoiding nextLong() because it uses a 48-bit generator so it can't cover the
			// entire space. This might not either but it might be a better approach.
			ThreadLocalRandom rng = ThreadLocalRandom.current();
			BigInteger bi = new BigInteger(64, rng);
			a.setR(bi.longValue());
			bi = new BigInteger(64, rng);
			a.setI(bi.longValue());
		}
	};

	@Override
	public Procedure1<GaussianInt64Member> random() {
		return RAND;
	}

	private final Procedure2<GaussianInt64Member, UnboundedIntMember> NORM =
			new Procedure2<GaussianInt64Member, UnboundedIntMember>()
	{
		@Override
		public void call(GaussianInt64Member a, UnboundedIntMember b) {
			BigInteger ar = BigInteger.valueOf(a.r);
			BigInteger ai = BigInteger.valueOf(a.i);
			BigInteger val = ar.multiply(ar).add(ai.multiply(ai));
			b.setV(val);
		}
	};

	@Override
	public Procedure2<GaussianInt64Member, UnboundedIntMember> norm() {
		return NORM;
	}

	private final Procedure2<GaussianInt64Member, GaussianInt64Member> CONJ =
			new Procedure2<GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b) {
			b.r = a.r;
			b.i = -a.i;
		}
	};

	@Override
	public Procedure2<GaussianInt64Member, GaussianInt64Member> conjugate() {
		return CONJ;
	}

	private final Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member> STWO =
			new Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(java.lang.Integer numTimes, GaussianInt64Member a, GaussianInt64Member b) {
			b.setR( a.r << numTimes );
			b.setI( a.i << numTimes );
		}
	};

	@Override
	public Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member> scaleByTwo() {
		return STWO;
	}

	private final Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member> SHALF =
			new Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(java.lang.Integer numTimes, GaussianInt64Member a, GaussianInt64Member b) {
			b.setR( a.r >> numTimes );
			b.setI( a.i >> numTimes );
		}
	};

	@Override
	public Procedure3<java.lang.Integer, GaussianInt64Member, GaussianInt64Member> scaleByOneHalf() {
		return SHALF;
	}

	private final Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> GCD =
			new Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member c) {
			EuclideanGcd.compute(G.GAUSS64, G.UNBOUND, a, b, c);
		}
	};

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> gcd() {
		return GCD;
	}

	private final Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> LCM =
			new Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member c) {
			EuclideanLcm.compute(G.GAUSS64, G.UNBOUND, a, b, c);
		}
	};

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> lcm() {
		return LCM;
	}

	private final Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> DIV =
			new Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member d) {
			GaussianInt64Member m = G.GAUSS64.construct();
			divMod().call(a, b, d, m);
		}
	};

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> div() {
		return DIV;
	}

	private final Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> MOD =
			new Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member m) {
			GaussianInt64Member d = G.GAUSS64.construct();
			divMod().call(a, b, d, m);
		}
	};

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> mod() {
		return MOD;
	}

	private final Procedure4<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> DIVMOD =
			new Procedure4<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(GaussianInt64Member a, GaussianInt64Member b, GaussianInt64Member d, GaussianInt64Member m) {
			// rather than define a tricky integer only algo I will project into complex space and translate back.
			GaussianInt64Member tmp = G.GAUSS64.construct();
			ComplexHighPrecisionMember ca = new ComplexHighPrecisionMember(BigDecimal.valueOf(a.r()), BigDecimal.valueOf(a.i()));
			ComplexHighPrecisionMember cb = new ComplexHighPrecisionMember(BigDecimal.valueOf(b.r()), BigDecimal.valueOf(b.i()));
			ComplexHighPrecisionMember cd = new ComplexHighPrecisionMember();
			G.CHP.divide().call(ca, cb, cd);
			if (cd.r().signum() < 0)
				cd.setR(cd.r().subtract(BigDecimalUtils.ONE_HALF));
			else
				cd.setR(cd.r().add(BigDecimalUtils.ONE_HALF));
			if (cd.i().signum() < 0)
				cd.setI(cd.i().subtract(BigDecimalUtils.ONE_HALF));
			else
				cd.setI(cd.i().add(BigDecimalUtils.ONE_HALF));
			d.setR( cd.r().longValue() );
			d.setI( cd.i().longValue() );
			G.GAUSS64.multiply().call(d, b, tmp);  // Order of ops doesn't matter since complex multiplication commutes
			G.GAUSS64.subtract().call(a, tmp, m);
		}
	};

	@Override
	public Procedure4<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> divMod() {
		return DIVMOD;
	}

	private final Function1<Boolean, GaussianInt64Member> EVEN =
			new Function1<Boolean, GaussianInt64Member>()
	{
		@Override
		public Boolean call(GaussianInt64Member a) {
			UnboundedIntMember norm = G.UNBOUND.construct();
			norm().call(a, norm);
			return norm.v().and(BigInteger.ONE).equals(BigInteger.ZERO);
		}
	};

	@Override
	public Function1<Boolean, GaussianInt64Member> isEven() {
		return EVEN;
	}

	private final Function1<Boolean, GaussianInt64Member> ODD =
			new Function1<Boolean, GaussianInt64Member>()
	{
		@Override
		public Boolean call(GaussianInt64Member a) {
			UnboundedIntMember norm = G.UNBOUND.construct();
			norm().call(a, norm);
			return norm.v().and(BigInteger.ONE).equals(BigInteger.ONE);
		}
	};

	@Override
	public Function1<Boolean, GaussianInt64Member> isOdd() {
		return ODD;
	}

	private final Procedure2<GaussianInt64Member, HighPrecisionMember> ABS =
			new Procedure2<GaussianInt64Member, HighPrecisionMember>()
	{
		@Override
		public void call(GaussianInt64Member a, HighPrecisionMember b) {
			UnboundedIntMember norm = G.UNBOUND.construct();
			norm().call(a, norm);
			BigDecimal n = new BigDecimal(norm.v());
			b.setV(BigDecimalMath.sqrt(n, HighPrecisionAlgebra.getContext()));
		}
	};

	@Override
	public Procedure2<GaussianInt64Member, HighPrecisionMember> abs() {
		return ABS;
	}

	private final Procedure3<RationalMember, GaussianInt64Member, GaussianInt64Member> SBR =
			new Procedure3<RationalMember, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(RationalMember factor, GaussianInt64Member a, GaussianInt64Member b) {
			long r = a.r();
			long i = a.i();
			r = BigInteger.valueOf(r).multiply(factor.n()).divide(factor.d()).longValue();
			i = BigInteger.valueOf(i).multiply(factor.n()).divide(factor.d()).longValue();
			b.setR(r);
			b.setI(i);
		}
	};

	@Override
	public Procedure3<RationalMember, GaussianInt64Member, GaussianInt64Member> scaleByRational() {
		return SBR;
	}

	private final Procedure3<HighPrecisionMember, GaussianInt64Member, GaussianInt64Member> SBHPR =
			new Procedure3<HighPrecisionMember, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(HighPrecisionMember factor, GaussianInt64Member a, GaussianInt64Member b) {
			BigDecimal br = BigDecimal.valueOf(a.r()).multiply(factor.v());
			BigDecimal bi = BigDecimal.valueOf(a.i()).multiply(factor.v());
			if (br.signum() < 0)
				br = br.subtract(BigDecimalUtils.ONE_HALF);
			else
				br = br.add(BigDecimalUtils.ONE_HALF);
			if (bi.signum() < 0)
				bi = bi.subtract(BigDecimalUtils.ONE_HALF);
			else
				bi = bi.add(BigDecimalUtils.ONE_HALF);
			b.setR(br.longValue());
			b.setI(bi.longValue());
		}
	};

	@Override
	public Procedure3<HighPrecisionMember, GaussianInt64Member, GaussianInt64Member> scaleByHighPrecAndRound() {
		return SBHPR;
	}

	private final Procedure3<HighPrecisionMember, GaussianInt64Member, GaussianInt64Member> SBHP =
			new Procedure3<HighPrecisionMember, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(HighPrecisionMember factor, GaussianInt64Member a, GaussianInt64Member b) {
			BigDecimal br = BigDecimal.valueOf(a.r()).multiply(factor.v());
			BigDecimal bi = BigDecimal.valueOf(a.i()).multiply(factor.v());
			b.setR(br.longValue());
			b.setI(bi.longValue());
		}
	};

	@Override
	public Procedure3<HighPrecisionMember, GaussianInt64Member, GaussianInt64Member> scaleByHighPrec() {
		return SBHP;
	}

	private final Procedure3<Double, GaussianInt64Member, GaussianInt64Member> SBDR =
			new Procedure3<Double, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(Double factor, GaussianInt64Member a, GaussianInt64Member b) {
			BigDecimal scale = new BigDecimal(factor);
			BigDecimal br = new BigDecimal(a.r()).multiply(scale);
			BigDecimal bi = new BigDecimal(a.i()).multiply(scale);
			if (br.signum() < 0)
				br = br.subtract(BigDecimalUtils.ONE_HALF);
			else
				br = br.add(BigDecimalUtils.ONE_HALF);
			if (bi.signum() < 0)
				bi = bi.subtract(BigDecimalUtils.ONE_HALF);
			else
				bi = bi.add(BigDecimalUtils.ONE_HALF);
			b.setR(br.longValue());
			b.setI(bi.longValue());
		}
	};

	@Override
	public Procedure3<Double, GaussianInt64Member, GaussianInt64Member> scaleByDoubleAndRound() {
		return SBDR;
	}

	private final Procedure3<Double, GaussianInt64Member, GaussianInt64Member> SBD =
			new Procedure3<Double, GaussianInt64Member, GaussianInt64Member>()
	{
		@Override
		public void call(Double factor, GaussianInt64Member a, GaussianInt64Member b) {
			BigDecimal scale = new BigDecimal(factor);
			BigDecimal br = new BigDecimal(a.r()).multiply(scale);
			BigDecimal bi = new BigDecimal(a.i()).multiply(scale);
			b.setR(br.longValue());
			b.setI(bi.longValue());
		}
	};

	@Override
	public Procedure3<Double, GaussianInt64Member, GaussianInt64Member> scaleByDouble() {
		return SBD;
	}

	@Override
	public Procedure3<GaussianInt64Member, GaussianInt64Member, GaussianInt64Member> scale() {
		return MUL;
	}

	private final Function1<Boolean, GaussianInt64Member> ISUNITY =
			new Function1<Boolean, GaussianInt64Member>()
	{
		@Override
		public Boolean call(GaussianInt64Member a) {
			return a.r() == 1 && a.i() == 0;
		}
	};

	@Override
	public Function1<Boolean,GaussianInt64Member> isUnity() {
		return ISUNITY;
	}
}


text:
package org.deviceconnect.android.deviceplugin.chromecast.profile;

/**
 * Constants for ChromeCast Receiver App Interface.
 * @author NTT DOCOMO, INC.
 */
interface ChromeCastConstants {

    /** Parameter key: {@value}. */
    String KEY_FUNCTION = "function";

    /** Parameter key: {@value}. */
    String KEY_MODE = "mode";

    /** Parameter key: {@value}. */
    String KEY_URL = "url";

    /** Parameter key: {@value}. */
    String KEY_X = "x";

    /** Parameter key: {@value}. */
    String KEY_Y = "y";

    /** Parameter key: {@value}. */
    String KEY_TYPE = "type";

    /** Parameter key: {@value}. */
    String KEY_MESSAGE = "message";

    /** Function type: {@value}. */
    String FUNCTION_POST_NOTIFICATION = "write";

    /** Function type: {@value}. */
    String FUNCTION_DELETE_NOTIFICATION = "clear";

    /** Function type: {@value}. */
    String FUNCTION_POST_IMAGE = "canvas_draw";

    /** Function type: {@value}. */
    String FUNCTION_DELETE_IMAGE = "canvas_delete";

}

redpajama_set_name: RedPajamaGithub


text:
require 'chef/knife/clc_base'

class Chef
  class Knife
    class ClcOperationShow < Knife
      include Knife::ClcBase

      banner 'knife clc operation show ID (options)'

      option :clc_wait,
        :long => '--wait',
        :description => 'Wait for operation completion',
        :boolean => true,
        :default => false,
        :on => :head

      def parse_and_validate_parameters
        unless name_args[0]
          errors << 'Operation ID is required'
        end
      end

      def execute
        operation_id = name_args[0]

        if config[:clc_wait]
          ui.info 'Waiting for operation completion...'
          connection.wait_for(operation_id) { putc '.' }
          ui.info "\n"
          ui.info 'Operation has been completed'
        else
          status = connection.show_operation(operation_id)['status']
          ui.info "#{ui.color('Status', :bold)}: #{status}"
        end
      end
    end
  end
end


text:
const electron = require('./');

const proc = require('child_process');

const child = proc.spawn(electron, process.argv.slice(2), { stdio: 'inherit', windowsHide: false });
child.on('close', function (code, signal) {
  if (code === null) {
    console.error(electron, 'exited with signal', signal);
    process.exit(1);
  }
  process.exit(code);
});

const handleTerminationSignal = function (signal) {
  process.on(signal, function signalHandler () {
    if (!child.killed) {
      child.kill(signal);
    }
  });
};

handleTerminationSignal('SIGINT');
handleTerminationSignal('SIGTERM');


text:
extern "C" {

#include <ccnet/peer.h>

}
#include <QtGui>
#include <QApplication>
#include <QDesktopServices>
#include <QSet>
#include <QDebug>

#include "seafile-applet.h"
#include "rpc/rpc-client.h"
#include "main-window.h"
#include "settings-dialog.h"
#include "settings-mgr.h"
#include "tray-icon.h"
#if defined(Q_WS_MAC)
#include "traynotificationmanager.h"
#endif

namespace {

const int kRefreshInterval = 5000;
const int kRotateTrayIconIntervalMilli = 250;

#if defined(Q_WS_WIN)
#include <windows.h>
bool
isWindowsVistaOrHigher()
{
    OSVERSIONINFOEX ver = {0};

    ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

    if (!GetVersionEx((LPOSVERSIONINFO)&ver)) {
        return false;
    }

    if (ver.dwMajorVersion >= 6) {
        return true;
    }

    return false;
}
#endif

}

SeafileTrayIcon::SeafileTrayIcon(QObject *parent)
    : QSystemTrayIcon(parent),
      nth_trayicon_(0),
      rotate_counter_(0)
{
    setToolTip(getBrand());
    setState(STATE_DAEMON_DOWN);
    rotate_timer_ = new QTimer(this);
    connect(rotate_timer_, SIGNAL(timeout()), this, SLOT(rotateTrayIcon()));

    refresh_timer_ = new QTimer(this);
    connect(refresh_timer_, SIGNAL(timeout()), this, SLOT(refreshTrayIcon()));

    createActions();
    createContextMenu();

    connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(onActivated(QSystemTrayIcon::ActivationReason)));

    hide();

#if defined(Q_WS_MAC)
    tnm = new TrayNotificationManager(this);
#endif
}

void SeafileTrayIcon::start()
{
    show();
    refresh_timer_->start(kRefreshInterval);
}

void SeafileTrayIcon::createActions()
{
    disable_auto_sync_action_ = new QAction(tr("Disable auto sync"), this);
    connect(disable_auto_sync_action_, SIGNAL(triggered()), this, SLOT(disableAutoSync()));

    enable_auto_sync_action_ = new QAction(tr("Enable auto sync"), this);
    connect(enable_auto_sync_action_, SIGNAL(triggered()), this, SLOT(enableAutoSync()));

    quit_action_ = new QAction(tr("&Quit"), this);
    connect(quit_action_, SIGNAL(triggered()), this, SLOT(quitSeafile()));

    toggle_main_window_action_ = new QAction(tr("Show main window"), this);
    connect(toggle_main_window_action_, SIGNAL(triggered()), this, SLOT(toggleMainWindow()));

    settings_action_ = new QAction(tr("Settings"), this);
    connect(settings_action_, SIGNAL(triggered()), this, SLOT(showSettingsWindow()));

    about_action_ = new QAction(tr("&About"), this);
    about_action_->setStatusTip(tr("Show the application's About box"));
    connect(about_action_, SIGNAL(triggered()), this, SLOT(about()));

    open_help_action_ = new QAction(tr("&Online help"), this);
    open_help_action_->setStatusTip(tr("open seafile online help"));
    connect(open_help_action_, SIGNAL(triggered()), this, SLOT(openHelp()));
}

void SeafileTrayIcon::createContextMenu()
{
    help_menu_ = new QMenu(tr("Help"), NULL);
    help_menu_->addAction(about_action_);
    help_menu_->addAction(open_help_action_);

    context_menu_ = new QMenu(NULL);
    context_menu_->addAction(toggle_main_window_action_);
    context_menu_->addAction(settings_action_);
    context_menu_->addMenu(help_menu_);
    context_menu_->addSeparator();
    context_menu_->addAction(enable_auto_sync_action_);
    context_menu_->addAction(disable_auto_sync_action_);
    context_menu_->addSeparator();
    context_menu_->addAction(quit_action_);

    setContextMenu(context_menu_);
    connect(context_menu_, SIGNAL(aboutToShow()), this, SLOT(prepareContextMenu()));
}

void SeafileTrayIcon::prepareContextMenu()
{
    if (seafApplet->settingsManager()->autoSync()) {
        enable_auto_sync_action_->setVisible(false);
        disable_auto_sync_action_->setVisible(true);
    } else {
        enable_auto_sync_action_->setVisible(true);
        disable_auto_sync_action_->setVisible(false);
    }

    if (!seafApplet->mainWindow()->isVisible()) {
        toggle_main_window_action_->setText(tr("Show main window"));
    } else {
        toggle_main_window_action_->setText(tr("Hide main window"));
    }
}

void SeafileTrayIcon::notify(const QString &title, const QString &content)
{
#if defined(Q_WS_MAC)
    QIcon icon(":/images/info.png");
    TrayNotificationWidget* trayNotification = new TrayNotificationWidget(icon.pixmap(32, 32), title, content);
    tnm->append(trayNotification);
#else
    this->showMessage(title, content);
#endif
}

void SeafileTrayIcon::rotate(bool start)
{
    if (start) {
        rotate_counter_ = 0;
        if (!rotate_timer_->isActive()) {
            nth_trayicon_ = 0;
            rotate_timer_->start(kRotateTrayIconIntervalMilli);
        }
    } else {
        rotate_timer_->stop();
    }
}

void SeafileTrayIcon::rotateTrayIcon()
{
    if (rotate_counter_ >= 8 || !seafApplet->settingsManager()->autoSync()) {
        rotate_timer_->stop();
        if (!seafApplet->settingsManager()->autoSync())
            setState (STATE_DAEMON_AUTOSYNC_DISABLED);
        else
            setState (STATE_DAEMON_UP);
        return;
    }

    TrayState states[] = { STATE_TRANSFER_1, STATE_TRANSFER_2 };
    int index = nth_trayicon_ % 2;
    setIcon(stateToIcon(states[index]));

    nth_trayicon_++;
    rotate_counter_++;
}

void SeafileTrayIcon::resetToolTip ()
{
    QString tip(getBrand());
    if (!seafApplet->settingsManager()->autoSync()) {
        tip = tr("auto sync is disabled");
    }

    setToolTip(tip);
}

void SeafileTrayIcon::setState(TrayState state)
{
    setIcon(stateToIcon(state));

    // the following two lines solving the problem of tray icon
    // disappear in ubuntu 13.04
#if defined(Q_WS_X11)
    hide();
    show();
#endif

    if (state != STATE_DAEMON_DOWN)
        resetToolTip();
}

QIcon SeafileTrayIcon::getIcon(const QString& name)
{
    if (icon_cache_.contains(name)) {
        return icon_cache_[name];
    }

    QIcon icon(name);
    icon_cache_[name] = icon;
    return icon;
}

QIcon SeafileTrayIcon::stateToIcon(TrayState state)
{
    state_ = state;
#if defined(Q_WS_WIN)
    QString prefix = ":/images/win/";

    switch (state) {
    case STATE_DAEMON_UP:
        return getIcon(prefix + "daemon_up.ico");
    case STATE_DAEMON_DOWN:
        return getIcon(prefix + "daemon_down.ico");
    case STATE_DAEMON_AUTOSYNC_DISABLED:
        return getIcon(prefix + "seafile_auto_sync_disabled.ico");
    case STATE_TRANSFER_1:
        return getIcon(prefix + "seafile_transfer_1.ico");
    case STATE_TRANSFER_2:
        return getIcon(prefix + "seafile_transfer_2.ico");
    case STATE_SERVERS_NOT_CONNECTED:
        return getIcon(prefix + "seafile_warning.ico");
    }
#elif defined(Q_WS_MAC)
    switch (state) {
    case STATE_DAEMON_UP:
        return getIcon(":/images/mac/daemon_up.png");
    case STATE_DAEMON_DOWN:
        return getIcon(":/images/mac/daemon_down.png");
    case STATE_DAEMON_AUTOSYNC_DISABLED:
        return getIcon(":/images/mac/seafile_auto_sync_disabled.png");
    case STATE_TRANSFER_1:
        return getIcon(":/images/mac/seafile_transfer_1.png");
    case STATE_TRANSFER_2:
        return getIcon(":/images/mac/seafile_transfer_2.png");
    case STATE_SERVERS_NOT_CONNECTED:
        return getIcon(":/images/mac/seafile_warning.png");
    }
#else
    switch (state) {
    case STATE_DAEMON_UP:
        return getIcon(":/images/daemon_up.png");
    case STATE_DAEMON_DOWN:
        return getIcon(":/images/daemon_down.png");
    case STATE_DAEMON_AUTOSYNC_DISABLED:
        return getIcon(":/images/seafile_auto_sync_disabled.png");
    case STATE_TRANSFER_1:
        return getIcon(":/images/seafile_transfer_1.png");
    case STATE_TRANSFER_2:
        return getIcon(":/images/seafile_transfer_2.png");
    case STATE_SERVERS_NOT_CONNECTED:
        return getIcon(":/images/seafile_warning.png");
    }
#endif
}

void SeafileTrayIcon::toggleMainWindow()
{
    MainWindow *main_win = seafApplet->mainWindow();
    if (!main_win->isVisible()) {
        main_win->showWindow();
    } else {
        main_win->hide();
    }
}

void SeafileTrayIcon::about()
{
    QMessageBox::about(seafApplet->mainWindow(), tr("About %1").arg(getBrand()),
                       tr("<h2>%1 Client %2</h2>").arg(getBrand()).arg(
                           STRINGIZE(SEAFILE_CLIENT_VERSION)));
}

void SeafileTrayIcon::openHelp()
{
    QString url;
    if (QLocale::system().name() == "zh_CN") {
        url = "http://seafile.com/help/install_v2/";
    } else {
        url = "http://seafile.com/en/help/install_v2/";
    }

    QDesktopServices::openUrl(QUrl(url));
}

void SeafileTrayIcon::showSettingsWindow()
{
    seafApplet->settingsDialog()->show();
    seafApplet->settingsDialog()->raise();
    seafApplet->settingsDialog()->activateWindow();
}

void SeafileTrayIcon::onActivated(QSystemTrayIcon::ActivationReason reason)
{
#ifndef Q_WS_MAC
    switch(reason) {
    case QSystemTrayIcon::Trigger: // single click
    case QSystemTrayIcon::MiddleClick:
    case QSystemTrayIcon::DoubleClick:
        toggleMainWindow();
        break;
    default:
        return;
    }
#endif
}

void SeafileTrayIcon::disableAutoSync()
{
    seafApplet->settingsManager()->setAutoSync(false);
}

void SeafileTrayIcon::enableAutoSync()
{
    seafApplet->settingsManager()->setAutoSync(true);
}

void SeafileTrayIcon::quitSeafile()
{
    seafApplet->exit(0);
}

void SeafileTrayIcon::refreshTrayIcon()
{
    bool all_server_connected = allServersConnected();
    if (state_ == STATE_DAEMON_UP && !all_server_connected) {
        setState(STATE_SERVERS_NOT_CONNECTED);
        setToolTip(tr("some servers not connected"));
    } else if (state_ == STATE_SERVERS_NOT_CONNECTED && all_server_connected) {
        setState(STATE_DAEMON_UP);
        setToolTip(getBrand());
    }
}

bool SeafileTrayIcon::allServersConnected()
{
    if (!seafApplet->started()) {
        return true;
    }

    GList *servers = NULL;
    if (seafApplet->rpcClient()->getServers(&servers) < 0) {
        return true;
    }

    if (!servers) {
        return true;
    }

    GList *ptr;
    bool all_server_connected = true;
    for (ptr = servers; ptr ; ptr = ptr->next) {
        CcnetPeer *server = (CcnetPeer *)ptr->data;
        if (server->net_state != PEER_CONNECTED) {
            all_server_connected = false;
            break;
        }
    }

    g_list_foreach (servers, (GFunc)g_object_unref, NULL);
    g_list_free (servers);

    return all_server_connected;
}


text:
using namespace v8;

void Graph::Init(Handle<Object> target) {
  // Prepare constructor template
  Local<FunctionTemplate> tpl = FunctionTemplate::New(New); // this calls the New member function
  tpl->SetClassName(String::NewSymbol("Graph"));
  tpl->InstanceTemplate()->SetInternalFieldCount(1);
  // Prototype

  tpl->PrototypeTemplate()->Set(String::NewSymbol("add_node"),
      FunctionTemplate::New(add_node)->GetFunction());

  tpl->PrototypeTemplate()->Set(String::NewSymbol("add_edge"),
  	  FunctionTemplate::New(add_edge)->GetFunction());

  tpl->PrototypeTemplate()->Set(String::NewSymbol("update_edge"),
      FunctionTemplate::New(update_edge)->GetFunction());

  tpl->PrototypeTemplate()->Set(String::NewSymbol("print"),
      FunctionTemplate::New(print)->GetFunction());

  tpl->PrototypeTemplate()->Set(String::NewSymbol("trim"),
      FunctionTemplate::New(trim)->GetFunction());

  tpl->PrototypeTemplate()->Set(String::NewSymbol("bellmanford"),
      FunctionTemplate::New(bellmanford)->GetFunction());

  Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction());
  target->Set(String::NewSymbol("Graph"), constructor);
}
// this is the "New member function"
Handle<Value> Graph::New(const Arguments& args) {
  HandleScope scope;

  Graph* obj = new Graph();
  obj->Wrap(args.This());
  return args.This();
}

Handle<Value> Graph::add_node(const v8::Arguments& args)
{
  HandleScope scope;

  if (args.Length() != 1 ) {
    ThrowException(Exception::TypeError(String::New("add_node: wrong number of arguments")));
    return scope.Close(Undefined());
  }

  Graph* graph = ObjectWrap::Unwrap<Graph>(args.This());

  v8::String::Utf8Value param(args[0]->ToString());
  std::string name = std::string(*param);

  graph->add_node( name );
  return scope.Close(Boolean::New(true));
}

Handle<Value> Graph::add_edge(const v8::Arguments& args)
{
  HandleScope scope;

  Graph* graph = ObjectWrap::Unwrap<Graph>(args.This());

  if( args.Length() == 3 ){
    v8::String::Utf8Value param1(args[0]->ToString());
    v8::String::Utf8Value param2(args[1]->ToString());

    std::string from = std::string(*param1);
    std::string to = std::string(*param2);
    double weight = args[2]->NumberValue();

    graph->add_edge( from, to, weight );
    return scope.Close(Boolean::New(true));

  } else {
    ThrowException(Exception::TypeError(String::New("add_edge: wrong number of arguments")));
    return scope.Close(Undefined());
  }
}

Handle<Value> Graph::update_edge(const v8::Arguments& args)
{
  HandleScope scope;

  Graph* graph = ObjectWrap::Unwrap<Graph>(args.This());
  if( args.Length() == 3 ){
    v8::String::Utf8Value param1(args[0]->ToString());
    v8::String::Utf8Value param2(args[1]->ToString());

    std::string from = std::string(*param1);
    std::string to = std::string(*param2);
    double weight = args[2]->NumberValue();

    graph->update_edge( from, to, weight );
    return scope.Close(Boolean::New(true));

  } else {
    ThrowException(Exception::TypeError(String::New("update_edge: wrong number of arguments")));
    return scope.Close(Undefined());
  }
}

Handle<Value> Graph::print(const v8::Arguments& args)
{
  HandleScope scope;

  Graph* graph = ObjectWrap::Unwrap<Graph>(args.This());
  graph->print();

  return scope.Close(Boolean::New(true));
}

Handle<Value> Graph::trim(const v8::Arguments& args)
{
  HandleScope scope;

  Graph* graph = ObjectWrap::Unwrap<Graph>(args.This());
  graph->trim();

  return scope.Close(Boolean::New(true));
}

Handle<Value> Graph::bellmanford(const v8::Arguments& args)
{
  HandleScope scope;
  std::vector<std::vector<std::string> > path;

  if( args.Length() != 1 ) {
    ThrowException(Exception::TypeError(String::New("bellmanford(source_node): wrong number of arguments")));
    return scope.Close(Undefined());
  }
  Graph* graph = ObjectWrap::Unwrap<Graph>(args.This());
  v8::String::Utf8Value param1(args[0]->ToString());
  std::string source = std::string(*param1);

  graph->bellman_ford(source, path);

  Handle<Array> result = Array::New(path.size());

  for(unsigned long int i = 0; i < path.size(); ++i){
    Handle<Array> keyvalue = Array::New(2);

    keyvalue->Set(0, String::New(path.at(i).at(0).c_str()));
    keyvalue->Set(1, String::New(path.at(i).at(1).c_str()));

    result->Set(i, keyvalue);
  }

  return scope.Close( result );

}

// #endif


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">Big Bang</string>
    <string name="title_person_detail">Person Detail</string>

</resources>


text:
function GetMafScaler() {
    if (GetMafScaler.prototype.instance === undefined) {
        GetMafScaler.prototype.instance = new MafScaler();
    }
    return GetMafScaler.prototype.instance;
}

var MafScaler = function() {
    this.Reset();
    this.colorMap = new Colormap($("#colormap").html());
};

MafScaler.prototype.ActivateTab = function() {
    var _this = this;
    var complete = function() {

        $("#maf-viewer-help").hide();
        $(".maf-viewer-controls").show();
        _this.RenderFuelingView();
    };
    if (GetLogView().LogsLoaded() && GetMapEdit().mapLoaded) {
        _this.perInjectorCompensationTable = GetMapEdit().LoadTable("Per Injector Pulse Width Compensation A");
        _this.mrpTable = GetMapEdit().LoadTable(Options.mrpTaleName);
        if (_this.mrpTable !== undefined && _this.mrpTable.address === undefined) {
            GetMapEdit().CachedTableList(GetMapEdit().map).done(function() {
                _this.mrpTable = GetMapEdit().LoadTable(_this.BestTable(Options.mrpTaleName));
                complete();
            });
        } else {
            complete();
        }

    } else {
        $(".maf-viewer-controls").hide();
        $("#maf-viewer-help").show();
    }

    GetGui().Ready();
};

MafScaler.prototype.Reset = function() {
    if (this.rendered) {
        $("#maf-chart").empty();
        $("#maf-error-scatter-chart").empty();
        $("#fueling-error-scatter-chart").empty();
        $("#maf-table-placeholder").empty();
        $("#corrected-maf-table-placeholder").empty();
        $("#injector-scale-placeholder").empty();
    }
    this.rendered = false;
    this.smoothed = false;
    this.fuelingTargetColumnName = "Primary Open Loop Fueling Target";
    this.fuelingErrorColumnName = "Open Loop Fueling Error (%)";
    this.closedLoopFuelingErrorColumnName = "Closed Loop Fueling Error (%)";
    this.fuelCCColumnName = "Fuel CC";
    this.calcFuelCCColumnName = "Calculated Fuel CC";
    this.calculatedClosedLoopFuelingTargetColumnName = "Calculated Closed Loop Fueling Target";
    this.estimatedAFRColumnName = "Estimated AFR";
    this.scatterData = [];
    this.loadCompScatterData = [];
    this.perInjectorScatterData = [];
    this.fuelCCScatterData = [];
    this.buckets = {};
    this.loadCompBuckets = {};
    this.loadCompAverages = {};
    this.perInjectorBuckets = {};
    this.perInjectorAverages = {};
    this.averages = [];
    this.loadCompensationMaxRpm = 4700;
};

function log10(val) {
  return Math.log(val) / Math.LN10;
}

MafScaler.prototype.RenderMafChart = function(tables) {

    var data = [];

    for (var t in tables) {
        var dataPoints = [];

        for (var d in tables[t].data) {
            dataPoints.push(
                {
                    //x: log10(parseFloat(tables[t].yAxis.data[d].display)),
                    //y: log10(parseFloat(tables[t].data[d].display))
                    x: parseFloat(tables[t].yAxis.data[d].display),
                    y: parseFloat(tables[t].data[d].display)
                });
        }
        data.push({
            type: "line",
            markerType: "none",
            showInLegend: true,
            name: tables[t].name,
            dataPoints : dataPoints
        });
    }

    var chart = new CanvasJS.Chart("maf-chart",
    {
      zoomEnabled: true,
      title : {

      },
      axisX:{
        title: tables[0].yAxis.name + " (" + tables[0].yAxis.scaling.units + ")"
      },

      axisY :{
        title: tables[0].scaling.units,
        includeZero:false
      },

      data: data,

    });

    chart.render();
};

MafScaler.prototype.RenderErrorScatter = function(id, nameX, nameY, points, averages, positiveDeviation, negativeDeviation) {

    var config = {
            title:{
                //text: "Import Cost Impact on Business",
                //fontFamily: "arial black",
                //fontColor: "DarkSlateGrey"
            },
            axisX: {
                title: nameX,
                titleFontSize: 14,
                labelFontSize: 12
                //titleFontFamily: "arial"

            },
            axisY:{
                title: nameY,
                //titleFontFamily: "arial",
                //valueFormatString:"0 USD",
                titleFontSize: 14,
                labelFontSize: 12
            },

            data: [
                {
                    type: "scatter",
                    dataPoints: points
                },
                {
                    type: "line",
                    markerType: "none",
                    dataPoints: averages
                }
            ]
        };

    if (typeof(positiveDeviation) != "undefined") {
        config.data.push(
            {
                type: "line",
                markerType: "none",
                dataPoints: positiveDeviation
            });
    }

    if (typeof(negativeDeviation) != "undefined") {
    config.data.push(
        {
            type: "line",
            markerType: "none",
            dataPoints: negativeDeviation
        });
    }

    var chart = new CanvasJS.Chart(id, config);

    chart.render();
};

MafScaler.prototype.GetTableIndex = function(table, x) {
    for (var i in table.yAxis.data) {
        if (table.yAxis.data[i].display == x) {
            return i;
        }
    }

    return undefined;
};

MafScaler.prototype.RenderErrorScatterChart = function() {
    var data = [];
    for (var s in this.scatterData) {
        var b = this.BestBucket(this.scatterData[s].x);
        if (this.buckets[b].length > Options.loadCompensationMinSamples) {
            if (this.scatterData[s].type == "closedLoop") {
                data.push({ x: this.scatterData[s].x, y: this.scatterData[s].y, markerColor: "rgba(58,135,173, 0.55)"});
            } else {
                data.push({ x: this.scatterData[s].x, y: this.scatterData[s].y, markerColor: "rgba(58,0,173, 0.55)"});
            }
        } else {
            data.push({ x: this.scatterData[s].x, y: this.scatterData[s].y, markerColor: "rgba(255, 0, 0, 0.25)"});
        }
    }
    this.RenderErrorScatter("maf-error-scatter-chart", Options.mafSensorVoltageColumnName, "Fuel Error (%)", data, this.averages);
};

MafScaler.prototype.RenderFuelingErrorScatterChart = function() {
    var column = $("#fueling-error-scatter-chart-select").val();
    var data = [];
    var min = Number.MAX_VALUE;
    var max = -Number.MAX_VALUE;
    for (var s in this.scatterData) {
        var value = parseFloat(this.scatterData[s].row[this.scatterData[s].header.indexOf(column)]);
        if (value > max) {
                max = value;
        }
        if (value < min) {
            min = value;
        }
        data.push({ x: value, y: this.scatterData[s].y, markerColor: "rgba(58,135,173, 0.55)"});
    }

    var b, buckets = {};

    var step = (max-min)/50;

    for (var x = min; x < max; x = x + step) {
        buckets[x] = [];
    }

    for (s in this.scatterData) {
        b = this.BestBucket(this.scatterData[s].row[this.scatterData[s].header.indexOf(column)], buckets);
        buckets[b].push(this.scatterData[s].y);
    }

    var averages = [];
    var positionDeviation = [];
    var negativeDeviation = [];

    for (b in buckets) {
        //average = this.AverageBucket(buckets[b], true);
        var stats = this.BucketStats(buckets[b]);
        if (stats !== undefined) {
            var average = stats.mean;
            if (!isNaN(average)) {
                averages.push( { y: average, x: parseFloat(b)});
            }
            average = stats.mean + stats.deviation;
            if (!isNaN(average)) {
                positionDeviation.push( { y: average, x: parseFloat(b)});
            }
            average = stats.mean - stats.deviation;
            if (!isNaN(average)) {
                negativeDeviation.push( { y: average, x: parseFloat(b)});
            }
        }
    }

    this.RenderErrorScatter("fueling-error-scatter-chart", "Randon Column", "Fuel Error (%)", data, averages, positionDeviation, negativeDeviation);
};

MafScaler.prototype.RenderLoadCompErrorChart = function() {
    if (this.mrpTable !== undefined) {
        var html = "

	";
        this.mrpTable.xAxis.data.forEach(function(x) {
            html += "" + x.display + "	";
        });

        html += "
";

        var _this = this, x;
        var min = Number.MAX_VALUE;
        var max = -Number.MAX_VALUE;

        var check = function(axisVal) {
            var y = parseFloat(axisVal.display);
            var value = _this.loadCompAverages[x][y];
            if (value > max) {
                    max = value;
            }
            if (value < min) {
                min = value;
            }
        };

        for (x in this.loadCompAverages) {
            this.mrpTable.xAxis.data.forEach(check);
        }

        var step;

        if (Math.abs(max - min) < 0.00000001) {
            step = 1;
        } else {
            step = (this.colorMap.length - 1) / (max - min);
        }

        var render = function(axisVal) {
            y = parseFloat(axisVal.display);
            var alpha = (_this.loadCompBuckets[x][y].length/averageBucketSize);
            var color = 255;
            var value = _this.loadCompAverages[x][y];
            var index = Math.floor((value - min) * step);
            color = _this.colorMap.map[index];
            var extraClass = "";
            if (_this.loadCompBuckets[x][y].length >= parseInt(Options.loadCompensationMinSamples, 10)) {
            } else {
                extraClass="update-ignore";
            }
            html += "" + sprintf("%0.2f", value) + "	";
        };

        for (x in this.loadCompAverages) {
            html += "
"+x+"	";
            this.mrpTable.xAxis.data.forEach(render);
            html += "
";
       }
       $("#rpm-error-scatter-chart").html(html);
    }
};

MafScaler.prototype.RenderPerInjectorErrorChart = function() {
    if (this.perInjectorCompensationTable !== undefined) {
        var html = "

	";
        this.perInjectorCompensationTable.xAxis.data.forEach(function(x) {
            html += "" + x.display + "	";
        });

        html += "
";

        var _this = this, x;
        var min = Number.MAX_VALUE;
        var max = -Number.MAX_VALUE;

        var check = function(axisVal) {
            var y = parseFloat(axisVal.display);
            var value = _this.perInjectorAverages[x][y];
            if (value > max) {
                    max = value;
            }
            if (value < min) {
                min = value;
            }
        };

        for (x in this.perInjectorAverages) {
            this.perInjectorCompensationTable.xAxis.data.forEach(check);
        }

        var step;

        if (Math.abs(max - min) < 0.00000001) {
            step = 1;
        } else {
            step = (this.colorMap.length - 1) / (max - min);
        }

        var render = function(axisVal) {
            y = parseFloat(axisVal.display);
            var alpha = (_this.perInjectorBuckets[x][y].length/perInjectorAverageBucketSize);
            var color = 255;
            var value = _this.perInjectorAverages[x][y];
            var index = Math.floor((value - min) * step);
            color = _this.colorMap.map[index];
            var extraClass = "";
            if (_this.perInjectorBuckets[x][y].length >= parseInt(Options.loadCompensationMinSamples, 10)) {
            } else {
                extraClass="update-ignore";
            }
            html += "" + sprintf("%0.2f", value) + "	";
        };

        for (x in this.perInjectorAverages) {
            html += "
"+x+"	";
            this.perInjectorCompensationTable.xAxis.data.forEach(render);
            html += "
";
       }
       $("#per-injector-error-scatter-chart").html(html);
    }
};

MafScaler.prototype.FindInjectorLine = function() {
    var data = [];
    var results = [];
    var min = Number.MAX_VALUE;
    var max = Number.MIN_VALUE;

    for (var d in this.fuelCCScatterData) {
        data.push(new Pair(this.fuelCCScatterData[d].x, this.fuelCCScatterData[d].y));
        if (this.fuelCCScatterData[d].x < min) {
            min = this.fuelCCScatterData[d].x;
        }
        if (this.fuelCCScatterData[d].x > max) {
            max = this.fuelCCScatterData[d].x;
        }
    }

    var result = matf.process_data(data,1);
    var p = result[0];

    for (var x = 0; x < max; x += 0.1) {
        results.push({x: x, y: matf.regress(x, p)});
    }

    return results;
};

MafScaler.prototype.SmoothAverages = function() {
    var data = [];
    var smoothed = clone(this.averages);

    for (var d in this.averages) {
        data.push(new Pair(this.averages[d].x, this.averages[d].y));
    }

    var result = matf.process_data(data,parseInt(Options.errorSmoothingFactor, 10));
    var p = result[0];

    for (d in this.averages) {
        if (this.averages[d].y == 0) {
            smoothed[d].y = 0;   // Not sure about this one
        } else {
            smoothed[d].y = matf.regress(this.averages[d].x, p);
        }
    }

    return smoothed;
};

MafScaler.prototype.ApplyCorrections = function() {

    for (var i in this.averages) {
        var index = this.GetTableIndex(this.correctedMafTable, this.averages[i].x);
        var value = this.correctedMafTable.data[index].value;
        var correction = this.averages[i].y / 100;
        var correctedValue = value + (value * correction);

        //if (parseFloat(this.selectedMafTable.yAxis.data[i].display) > 1.2) { //TODO: add option
            this.correctedMafTable.data[index].value = correctedValue;
            this.correctedMafTable.data[index].display = sprintf(this.correctedMafTable.scaling.format, correctedValue);
        //}

    }
};

MafScaler.prototype.SmoothCurve = function() {

    var data = [];
    var table = this.correctedMafTable;
    var smoothed = this.smoothedMafTable;

    for (var d in table.data) {
        data.push(new Pair(parseFloat(table.yAxis.data[d].display), parseFloat(table.data[d].display)));

    }

    var result = matf.process_data(data,parseInt(Options.smoothingFactor, 10));
    var p = result[0];

    for (d in table.data) {
        var x = parseFloat(smoothed.yAxis.data[d].display);
        if (x > parseFloat(Options.mafSmoothAbove)) {
            smoothed.data[d].value = matf.regress(x, p);
            smoothed.data[d].display = sprintf(smoothed.scaling.format, smoothed.data[d].value);
        } else {
            smoothed.data[d].value = table.data[d].value;
            smoothed.data[d].display = table.data[d].display;
        }
    }
};

MafScaler.prototype.RenderMaf = function() {
    RenderTemplate("#table-2D-template", this.selectedMafTable, "#corrected-maf-table-placeholder");
    this.RenderMafChart([this.mafTable, this.selectedMafTable]);
};

MafScaler.prototype.RenderInjectorScalingErrorScatter = function() {

    var injectorLine = this.FindInjectorLine();
    this.RenderErrorScatter("injector-scale-placeholder", "Pulse Width (ms)", "Fuel CC", this.fuelCCScatterData, injectorLine);

    var l = injectorLine.length-1;

    var scale = sprintf("%0.2f", ((injectorLine[l].y - injectorLine[0].y)/(injectorLine[l].x - injectorLine[0].x))*1000*60);
    $("#injector-scaling").html(scale);
};

MafScaler.prototype.RenderFuelingView = function() {
    if (GetLogView().LogsLoaded()) {
        var map = GetMapEdit().map;
        if (!this.rendered) {
            this.mafTable = GetMapEdit().LoadTable(Options.mafTableName);
            this.correctedMafTable =  clone(this.mafTable);
            this.correctedMafTable.name += " Corrected";
            this.smoothedMafTable =  clone(this.mafTable);
            this.smoothedMafTable.name += " Corrected (Smoothed)";
            this.selectedMafTable = this.correctedMafTable;
            RenderTemplate("#table-2D-template", this.mafTable, "#maf-table-placeholder");
            this.CollectResults();

            this.ApplyCorrections();
            this.SmoothCurve();
            this.RenderMaf();
            this.RenderErrorScatterChart();
            this.RenderLoadCompErrorChart();
            this.RenderPerInjectorErrorChart();
            this.RenderInjectorScalingErrorScatter();
            this.rendered = true;
        }
    }
};

MafScaler.prototype.ProcessLog = function(csv) {
    var errorColumn;
    var closedLoopErrorColumn;
    var mafVoltageColumn;
    var rpmColumn;
    var mprColumn;
    var fuelCCColumn;
    var calcFuelCCColumn;
    var estimatedAFRColumn;
    var pulseWidthColumn;
    var latencyColumn;
    var idcColumn;

    for (var r in csv.data) {
        if (r == 0) {
            for (var c in csv.data[r]) {
                if (csv.data[r][c] == Options.mafSensorVoltageColumnName) {
                    mafVoltageColumn = c;
                }
                if (csv.data[r][c] == this.fuelingErrorColumnName) {
                    errorColumn = c;
                }
                if (csv.data[r][c] == this.closedLoopFuelingErrorColumnName) {
                    closedLoopErrorColumn = c;
                }
                if (csv.data[r][c] == Options.manifoldPressureRelativeColumnName) {
                    mprColumn = c;
                }
                if (csv.data[r][c] == Options.engineSpeedColumnName) {
                    rpmColumn = c;
                }
                if (csv.data[r][c] == this.fuelCCColumnName) {
                    fuelCCColumn = c;
                }
                if (csv.data[r][c] == this.calcFuelCCColumnName) {
                    calcFuelCCColumn = c;
                }
                if (csv.data[r][c] == this.estimatedAFRColumnName) {
                    estimatedAFRColumn = c;
                }
                if (csv.data[r][c] == Options.pulseWidthColumnName) {
                    pulseWidthColumn = c;
                }
                if (csv.data[r][c] == Options.latencyColumnName) {
                    latencyColumn = c;
                }
                if (csv.data[r][c] == Options.injectorDutyCycleColumnName) {
                    idcColumn = c;
                }

                $("#fueling-error-scatter-chart-select").append("<option>" + csv.data[r][c] + "</option>")
            }

        } else {
            var mafVoltage = csv.data[r][mafVoltageColumn];
            var error = parseFloat(csv.data[r][errorColumn]);
            var closedLoopError = parseFloat(csv.data[r][closedLoopErrorColumn]);
            var rpm = csv.data[r][rpmColumn];
            var mpr = csv.data[r][mprColumn];
            var fuelCC = parseFloat(csv.data[r][fuelCCColumn]);
            var calcFuelCC = parseFloat(csv.data[r][calcFuelCCColumn]);
            var estimatedAFR = parseFloat(csv.data[r][estimatedAFRColumn]);
            var pulseWidth = parseFloat(csv.data[r][pulseWidthColumn]);
            var latency = latencyColumn !== undefined ? parseFloat(csv.data[r][latencyColumn]) : 0.0;
            var idc = parseFloat(csv.data[r][idcColumn]);
            //var pulseWidth = (idc * 1200) / rpm;

            if (!isNaN(error) && !isNaN(closedLoopError) && error != "undefined" && closedLoopError != "undefined") {
                gui.log("MafScaler.ProcessLog: Warning - Found open and closed loop errors in the same row ["+r+"] " + error + " " + closedLoopError);
            }
            if (!isNaN(error) && error !== undefined) {
                this.scatterData.push({x: parseFloat(mafVoltage), y: error, type: "openLoop", row: csv.data[r], header: csv.data[0]});
            }

            if (!isNaN(closedLoopError) && closedLoopError !== undefined) {
                this.scatterData.push({x: parseFloat(mafVoltage), y: closedLoopError,  type: "closedLoop", row: csv.data[r], header: csv.data[0]});
                this.loadCompScatterData.push({x: parseFloat(rpm), y: parseFloat(mpr), z: closedLoopError});
                this.perInjectorScatterData.push({x: parseFloat(rpm), y: parseFloat(pulseWidth), z: closedLoopError});
            }

            if (!isNaN(fuelCC)) {
                this.fuelCCScatterData.push({x: pulseWidth, y: fuelCC});
            }
        }
    }
};

MafScaler.prototype.BestBucket = function(v, buckets) {
    var diff = Number.MAX_VALUE;
    var index = 0;

    var _buckets;
    if (typeof(buckets) == "undefined") {
        _buckets = this.buckets;
    } else {
        _buckets = buckets;
    }

    for (var b in _buckets) {
        var d = Math.abs(v - b) ;
        if (d < diff) {
            index = b;
            diff = d;
        }
    }

    return index;
};

MafScaler.prototype.LoadCompBestBucket = function(rpm, mrp) {
    var diff = Number.MAX_VALUE;
    var x = 0, y = 0, d = 0;

    for (var r in this.loadCompBuckets) {
         d = Math.abs(rpm - r) ;
        if (d < diff) {
            x = r;
            diff = d;
        }
    }

    diff = Number.MAX_VALUE;

    for (var m in this.loadCompBuckets[r]) {
        d = Math.abs(mrp - m) ;
        if (d < diff) {
            y = m;
            diff = d;
        }
    }

    return {x: x, y: y};
};

MafScaler.prototype.PerInjectorBestBucket = function(rpm, pw) {
    var diff = Number.MAX_VALUE;
    var x = 0, y = 0, d = 0;

    for (var r in this.perInjectorBuckets) {
         d = Math.abs(rpm - r) ;
        if (d < diff) {
            x = r;
            diff = d;
        }
    }

    diff = Number.MAX_VALUE;

    for (var m in this.perInjectorBuckets[r]) {
        d = Math.abs(pw - m) ;
        if (d < diff) {
            y = m;
            diff = d;
        }
    }

    return {x: x, y: y};
};

MafScaler.prototype.AverageBucket = function(bucket, filter) {
    if (filter && bucket.length > 0 && bucket.length < Options.loadCompensationMinSamples) {
        return 0.0;
    } else {
        var total = 0;
        for (var i in bucket) {
            total += bucket[i];
        }
        return total /  bucket.length;
    }
};

MafScaler.prototype.BucketStats = function(a) {
    if (a.length === 0 || a.length < Options.loadCompensationMinSamples) {
        return undefined;
    }
    var r = {mean: 0, variance: 0, deviation: 0}, t = a.length;
    for(var m, s = 0, l = t; l--; s += a[l]);
    for(m = r.mean = s / t, l = t, s = 0; l--; s += Math.pow(a[l] - m, 2));
    return r.deviation = Math.sqrt(r.variance = s / t), r;
}

MafScaler.prototype.CollectResults = function() {

    var _this = this, x, y, i, s, b, average;

    for (var c in GetLogView().csvs) {
        this.ProcessLog(GetLogView().GetCsv(c));
    }

    var t = this.mafTable;

    for (i in this.mafTable.yAxis.data) {
        this.buckets[parseFloat(this.mafTable.yAxis.data[i].display)] = [];
    }

    if (this.mrpTable !== undefined) {
        this.mrpTable.yAxis.data.forEach(function(yAxisVal) {
            var rpm = parseInt(yAxisVal.display, 10);
            _this.loadCompBuckets[rpm] = {};
            _this.loadCompAverages[rpm] = {};
            _this.mrpTable.xAxis.data.forEach(function(axisVal) {
                var val = parseFloat(axisVal.display);
                _this.loadCompBuckets[rpm][val] = [];
                _this.loadCompAverages[rpm][val] = 0;
            });
        });

        for (s in this.loadCompScatterData) {
            x = this.loadCompScatterData[s].x;
            y = this.loadCompScatterData[s].y;
            b = this.LoadCompBestBucket(x, y);
            this.loadCompBuckets[b.x][b.y].push(this.loadCompScatterData[s].z);
        }
    }

     if (this.perInjectorCompensationTable !== undefined) {
        this.perInjectorCompensationTable.yAxis.data.forEach(function(yAxisVal) {
            var rpm = parseInt(yAxisVal.display, 10);
            _this.perInjectorBuckets[rpm] = {};
            _this.perInjectorAverages[rpm] = {};
            _this.perInjectorCompensationTable.xAxis.data.forEach(function(axisVal) {
                var val = parseFloat(axisVal.display);
                _this.perInjectorBuckets[rpm][val] = [];
                _this.perInjectorAverages[rpm][val] = 0;
            });
        });

        for (s in this.perInjectorScatterData) {
            x = this.perInjectorScatterData[s].x;
            y = this.perInjectorScatterData[s].y;
            b = this.PerInjectorBestBucket(x, y);
            if (this.perInjectorBuckets[b.x][b.y] !== undefined) {
                this.perInjectorBuckets[b.x][b.y].push(this.perInjectorScatterData[s].z);
            }
        }
    }

    for (s in this.scatterData) {
        b = this.BestBucket(this.scatterData[s].x);
        this.buckets[b].push(this.scatterData[s].y);
    }

    for (b in this.buckets) {
        average = this.AverageBucket(this.buckets[b], true);
        if (!isNaN(average)) {
            this.averages.push( { y: average, x: parseFloat(b)});
        }
    }

    averageBucketSize = 0;
    var nonEmptyBuckets = 0;

    for (x in this.loadCompBuckets) {
        for (y in this.loadCompBuckets[x]) {
            average = this.AverageBucket(this.loadCompBuckets[x][y], false);

            if (!isNaN(average)) {
                if (this.loadCompBuckets[x][y].length > 0) {
                    averageBucketSize += this.loadCompBuckets[x][y].length;
                    nonEmptyBuckets++;
                }
                this.loadCompAverages[x][y] = average;
            }
        }
    }

    averageBucketSize = averageBucketSize / nonEmptyBuckets;

    perInjectorAverageBucketSize = 0;
    nonEmptyBuckets = 0;

    for (x in this.perInjectorBuckets) {
        for (y in this.perInjectorBuckets[x]) {
            average = this.AverageBucket(this.perInjectorBuckets[x][y], false);

            if (!isNaN(average)) {
                if (this.perInjectorBuckets[x][y].length > 0) {
                    perInjectorAverageBucketSize += this.perInjectorBuckets[x][y].length;
                    nonEmptyBuckets++;
                }
                this.perInjectorAverages[x][y] = average;
            }
        }
    }

    perInjectorAverageBucketSize = perInjectorAverageBucketSize / nonEmptyBuckets;

    if (parseInt(Options.errorSmoothingFactor, 10) > 0) {
        this.averages = this.SmoothAverages();
    }
};

var levenshteinDistance = function(u, v) {
        var i, j;
        var m = u.length;
        var n = v.length;
        var D = [];
        for(i = 0; i <= m; i++) {
            D.push([]);
            for(j = 0; j <= n; j++) {
                D[i][j] = 0;
            }
        }
        for(i = 1; i <= m; i++) {
            for(j = 1; j <= n; j++) {
                if (j == 0) {
                    D[i][j] = i;
                } else if (i == 0) {
                    D[i][j] = j;
                } else {
                    D[i][j] = [D[i-1][j-1] + (u[i-1] != v[j-1]), D[i][j-1] + 1, D[i-1][j] + 1].sort()[0];
                }
            }
        }
        return D[m][n];
    };

MafScaler.prototype.BestColumn = function(data, name)  {
    var d = Number.MAX_VALUE, c;
    for (var i in data) {
        var distance = levenshteinDistance(data[i].split(" "), name.split(" "));
        if (distance < d) {
            d = distance;
            c = i;
        }
    }

    if (data[c] != name) {
        gui.log("MafScaler.BestColumn: Warning - Guessing " + data[c]  + " for " + name);
    }

    return c;
};

MafScaler.prototype.BestTable = function(name)  {
    var me = GetMapEdit();

    var d = Number.MAX_VALUE, c;
    for (var i in me.tables) {
        var distance = levenshteinDistance(me.tables[i].name.split(" "), name.split(" "));
        if (distance < d) {
            d = distance;
            c = i;
        }
    }

    if (me.tables[c].name != name) {
        gui.log("MafScaler.BestTable: Warning - Guessing " + me.tables[c].name  + " for " + name);
    }

    return me.tables[c].name;
};

MafScaler.prototype.MafScale = function(map, csv) {
    var tipInWarning = false, afLearning3Warning = false, afCorrection3Warning = false;
    var table = map.LoadTable(Options.targetFuelingMap);

    var afLearningColumn;
    var afCorrectionColumn;
    var afLearning3Column;
    var afCorrection3Column;
    var coolantColumn;
    var loadColumn;
    var speedColumn;
    var afrColumn;
    var oemAfrColumn;
    var throttleColumn;
    var closedLoopFuelingTargetColumn;
    var clOlColumn;
    var tipInThrottleColumn;
    var fuelingTargetColumn;
    var fuelingErrorColumn;
    var closedLoopFuelingErrorColumn;
    var mafColumn;
    var mafSensorVoltageColumn;
    var iatColumn;
    var fuelCCColumn;
    var pulseWidthColumn;
    var latencyColumn;

    for (var r in csv.data) {
        if (r == 0) { // no === here!
            if (csv.data[r].indexOf(this.fuelingTargetColumnName) == -1) {
                csv.data[r].push(this.fuelingTargetColumnName);
            }
            if (csv.data[r].indexOf(this.fuelingErrorColumnName) == -1) {
                csv.data[r].push(this.fuelingErrorColumnName);
            }
            if (csv.data[r].indexOf(this.closedLoopFuelingErrorColumnName) == -1) {
                csv.data[r].push(this.closedLoopFuelingErrorColumnName);
            }
            if (csv.data[r].indexOf(this.fuelCCColumnName) == -1) {
                csv.data[r].push(this.fuelCCColumnName);
            }
            if (csv.data[r].indexOf(this.fuelCCColumnName) == -1) {
                csv.data[r].push(this.fuelCCColumnName);
            }
            if (csv.data[r].indexOf(this.calcFuelCCColumnName) == -1) {
                csv.data[r].push(this.calcFuelCCColumnName);
            }
            if (csv.data[r].indexOf(this.estimatedAFRColumnName) == -1) {
                csv.data[r].push(this.estimatedAFRColumnName);
            }

            for (var c in csv.data[r]) {
                if (csv.data[r][c] == Options.closedLoopFuelingTargetColumnName) {
                    closedLoopFuelingTargetColumn = c;
                }
                if (csv.data[r][c] == Options.afCorrectionColumnName) {
                    afCorrectionColumn = c;
                }
                if (csv.data[r][c] == Options.afLearningColumnName) {
                    afLearningColumn = c;
                }
                if (csv.data[r][c] == Options.engineLoadColumnName) {
                    loadColumn = c;
                }
                if (csv.data[r][c] == Options.afCorrection3ColumnName) {
                    afCorrection3Column = c;
                }
                if (csv.data[r][c] == Options.afLearning3ColumnName) {
                    afLearning3Column = c;
                }
                if (csv.data[r][c] == Options.engineSpeedColumnName) {
                    speedColumn = c;
                }
                if (csv.data[r][c] == Options.afrColumnName) {
                    afrColumn = c;
                }
                if (csv.data[r][c] == Options.oemAfrColumnName) {
                    oemAfrColumn = c;
                }
                 if (csv.data[r][c] == Options.coolantTempColumnName) {
                    coolantColumn = c;
                }
                if (csv.data[r][c] == Options.throttleColumnName) {
                    throttleColumn = c;
                }
                if (csv.data[r][c] == Options.clOlFuelingColumnName) {
                    clOlColumn = c;
                }
                if (csv.data[r][c] == Options.tipInThrottleColumnName) {
                    tipInThrottleColumn = c;
                }
                if (csv.data[r][c] == this.fuelingErrorColumnName) {
                    fuelingErrorColumn = c;
                }
                if (csv.data[r][c] == this.closedLoopFuelingErrorColumnName) {
                    closedLoopFuelingErrorColumn = c;
                }
                if (csv.data[r][c] == this.fuelingTargetColumnName) {
                    fuelingTargetColumn = c;
                }
                if (csv.data[r][c] == Options.mafColumnName) {
                    mafColumn = c;
                }
                if (csv.data[r][c] == Options.mafSensorVoltageColumnName) {
                    mafSensorVoltageColumn = c;
                }
                if (csv.data[r][c] == Options.intakeAirTempColumnName) {
                    iatColumn = c;
                }
                if (csv.data[r][c] == Options.pulseWidthColumnName) {
                    pulseWidthColumn = c;
                }
                if (csv.data[r][c] == Options.latencyColumnName) {
                    latencyColumn = c;
                }
                if (csv.data[r][c] == this.fuelCCColumnName) {
                    fuelCCColumn = c;
                }
                if (csv.data[r][c] == this.calcFuelCCColumnName) {
                    calcFuelCCColumn = c;
                }
                if (csv.data[r][c] == this.estimatedAFRColumnName) {
                    estimatedAFRColumn = c;
                }
            }

            if ( pulseWidthColumn === undefined) {
                pulseWidthColumn = this.BestColumn(csv.data[r], Options.pulseWidthColumnName);
            }

            if (closedLoopFuelingTargetColumn === undefined) {
                closedLoopFuelingTargetColumn = this.BestColumn(csv.data[r], Options.closedLoopFuelingTargetColumnName);
                //gui.log("MafScaler.MafScale: Warning - Guessing " + csv.data[r][closedLoopFuelingTargetColumnName] + " for CL fueling target");
            }
            if (afCorrectionColumn === undefined) {
                afCorrectionColumn = this.BestColumn(csv.data[r], Options.afCorrectionColumnName);
                //gui.log("MafScaler.MafScale: Warning - Guessing " + csv.data[r][afCorrectionColumn] + " for af correction");
            }
            if (afLearningColumn === undefined) {
                afLearningColumn = this.BestColumn(csv.data[r], Options.afLearningColumnName);
                //gui.log("MafScaler.MafScale: Warning - Guessing " + csv.data[r][afLearningColumn] + " for af learning");
            }
            if (loadColumn === undefined) {
                loadColumn = this.BestColumn(csv.data[r], Options.engineLoadColumnName);
                //gui.log("MafScaler.MafScale: Warning - Guessing " + csv.data[r][loadColumn] + " for engine load");
            }
            if (clOlColumn === undefined) {
                clOlColumn = this.BestColumn(csv.data[r], Options.clOlFuelingColumnName);
                //gui.log("MafScaler.MafScale: Warning - Guessing " + csv.data[r][clOlColumn] + " for CL/OL fueling");
            }

        } else {
            if (isNaN(csv.data[r][0])) {
                  gui.log("MafScaler.MafScale: Warning - Log restart detected");
            } else {
                var load = csv.data[r][loadColumn];
                var speed = parseFloat(csv.data[r][speedColumn]);
                var afr = parseFloat(csv.data[r][afrColumn]);
                var oemAfr = parseFloat(csv.data[r][oemAfrColumn]);
                var clOl = csv.data[r][clOlColumn];
                var tipInThrottle = parseFloat(csv.data[r][tipInThrottleColumn]);
                var coolantTemp = parseFloat(csv.data[r][coolantColumn]);
                var maf = parseFloat(csv.data[r][mafColumn]);
                var mafV = parseFloat(csv.data[r][mafSensorVoltageColumn]);
                var iat = parseFloat(csv.data[r][iatColumn]);

                var afCorrection = csv.data[r][afCorrectionColumn];
                var afLearning = csv.data[r][afLearningColumn];
                var afCorrection3 = csv.data[r][afCorrection3Column];
                var afLearning3 = csv.data[r][afLearning3Column];
                var closedLoopFuelingTarget = csv.data[r][closedLoopFuelingTargetColumn];

                var error, target = parseFloat(map.Get3D(table, load, speed).toFixed(2));

                var pulseWidth = parseFloat(csv.data[r][pulseWidthColumn]);
                var latency = latencyColumn !== undefined ? parseFloat(csv.data[r][latencyColumn]) : 0.0;

                csv.data[r][fuelingTargetColumn]= sprintf("%.2f", target);

                if (isNaN(afCorrection3)) {
                    if (!afCorrection3Warning) {
                        //gui.log("MafScaler.MafScale: Warning - No AF Correction #3 data");
                        afCorrection3Warning = true;
                    }
                    afCorrection3 = 0.0;
                }
                if (isNaN(afLearning3)) {
                    if (!afLearning3Warning) {
                        //gui.log("MafScaler.MafScale: Warning - No AF Learning #3 data");
                        afLearning3Warning = true;
                    }
                    afLearning3 = 0.0;
                }
                if (isNaN(tipInThrottle)) {
                    if (!tipInWarning) {
                        gui.log("MafScaler.MafScale: Warning - No tip in data");
                        tipInWarning = true;
                    }
                    tipInThrottle = 0.0;
                }

                if ((Options.minCoolantTemp == 0 && Options.maxInletAirTemp == 0) || coolantTemp > Options.minCoolantTemp && iat < Options.maxInletAirTemp )
                {
                    if (clOl == "10"
                    //&&  afr <= 13.0 && afr >= 8.5) {
                    && csv.data[r][throttleColumn] >= 30 && afr <= 13.0 && afr >= 8.5) {

                        error = 100.0 * ((afr / target) - 1.0);
                        csv.data[r][fuelingErrorColumn] = sprintf("%.2f", 100 * ((afr / target) - 1.0));
                        csv.data[r][closedLoopFuelingErrorColumn] = undefined;
                    } else {
                        if (clOl == "8" && tipInThrottle === 0.0 && oemAfr <= 16.0 && oemAfr >= 13.0)
                        {
                            error = parseFloat(100.0 * ((oemAfr / closedLoopFuelingTarget) - 1.0)) + parseFloat(afCorrection) + parseFloat(afLearning) + parseFloat(afLearning3) + parseFloat(afCorrection3);
                            csv.data[r][closedLoopFuelingErrorColumn] = sprintf("%.2f", error);
                            csv.data[r][fuelingErrorColumn] = undefined;

                        }
                    }

                    if (clOl == "8" && oemAfr <= 16.0 && oemAfr >= 13.0 && speed < 4500.0 && maf > 0 && maf < 100 && tipInThrottle === 0.0) { // todo mafv/dt
                         csv.data[r][fuelCCColumn] = (load / 2 / oemAfr * 1000 / 748).toString();
                    } else {
                        csv.data[r][fuelCCColumn] = undefined;
                    }

                }

                var cc = (950/1000/60) * pulseWidth;

                if (clOl == "8" && cc > 0.000001) {
                    csv.data[r][calcFuelCCColumn] = ((950/1000/60) * pulseWidth).toString();
                    csv.data[r][estimatedAFRColumn] = (((100+error)/100)*((load/2)/(cc*748/1000))).toString();
                } else {
                    csv.data[r][estimatedAFRColumn] = "14.7";
                    csv.data[r][calcFuelCCColumn] = "0.0";
                }
            }
        }
    }

};

MafScaler.prototype.UpdateMrpMap = function() {

    var value, map = GetMapEdit().map;
    for (var y in this.mrpTable.yAxis.data) {
        for (var x in this.mrpTable.xAxis.data) {

            var _y = parseFloat(this.mrpTable.xAxis.data[x].display, 10);
            var _x = parseFloat(this.mrpTable.yAxis.data[y].display);

            value = this.loadCompAverages[_x][_y];

            if (value !== undefined) {
                if (this.loadCompBuckets[_x][_y].length >= parseInt(Options.loadCompensationMinSamples, 10)) {
                    var old = parseFloat(map.GetTable3D(this.mrpTable, x, y));
                    map.UpdateTable3D(this.mrpTable, x, y, value+old) ;
                }
            }
        }
    }

    GetMapEdit().RefreshTable(Options.mrpTaleName);

    gui.log("MafScaler.UpdateMrpMap: Updated Load Compensation table [" + Options.mrpTaleName + "]");
};

MafScaler.prototype.UpdateMap = function() {

    for (var i in this.selectedMafTable.data) {
        //if (this.selectedMafTable.yAxis.data[i].value > 1.7) {
            GetMapEdit().map.UpdateTable2D(this.selectedMafTable, parseInt(i, 10), this.selectedMafTable.data[i].value);
    //    }
    }

     GetMapEdit().RefreshTable(Options.mafTableName);

    gui.log("MafScaler.UpdateMrpMap: Updated MAF Sensor Scaling table [" + Options.mafTableName + "]");
};

MafScaler.prototype.GetErrorForVoltage = function(mafVoltage) {
    var bucket = GetMafScaler().BestBucket(mafVoltage);
    var found = false;
    for (var i in this.averages) {
        if (this.averages[i].x == bucket) {
            return this.averages[i].y;
        }
    }
};

MafScaler.prototype.GetErrorForMrpRpm = function(mrp, rpm) {
    var bucket = this.LoadCompBestBucket(rpm, mrp);
    return this.loadCompAverages[bucket.x][bucket.y];
};

MafScaler.prototype.UpdateAFLearing = function() {
    var map = GetMapEdit().map;
    for (var c in GetLogView().csvs) {
        this.UpdateAFLearingToLog(map, GetLogView().GetCsv(c));
    }

    this.Reset();
    this.RenderFuelingView();

    gui.log("MafScaler.UpdateAFLearing: Updated AF Learning log column!");
};

MafScaler.prototype.UpdateAFLearingToLog = function(map, csv) {

    var afLearningColumn, mafSensorVoltageColumn;
    for (var r in csv.data) {

        if (r == 0) { // no === here!
            for (var c in csv.data[r]) {
                if (csv.data[r][c] == Options.afLearningColumnName) {
                    afLearningColumn = c;
                }
                if (csv.data[r][c] == Options.mafSensorVoltageColumnName) {
                    mafSensorVoltageColumn = c;
                }
            }
        } else {
            var voltage = csv.data[r][mafSensorVoltageColumn];
            var error = parseFloat(this.GetErrorForVoltage(voltage));
            csv.data[r][afLearningColumn] = (parseFloat(csv.data[r][afLearningColumn]) - error).toString();
        }
    }

    this.MafScale(map, csv);
};

MafScaler.prototype.UpdateAFLearingFromLoadComp = function() {
    var map = GetMapEdit().map;
    for (var c in GetLogView().csvs) {
        this.UpdateAFLearingFromLoadCompToLog(map, GetLogView().GetCsv(c));
    }

    this.Reset();
    this.RenderFuelingView();

    gui.log("MafScaler.UpdateAFLearingFromLoadCompToLog: Updated AF Learning log column!");
};

MafScaler.prototype.UpdateAFLearingFromLoadCompToLog = function(map, csv) {

    var afLearningColumn, mprColumn, rpmColumn;
    for (var r in csv.data) {

        if (r == 0) { // no === here!
            for (var c in csv.data[r]) {
                if (csv.data[r][c] == Options.afLearningColumnName) {
                    afLearningColumn = c;
                }
                if (csv.data[r][c] == Options.manifoldPressureRelativeColumnName) {
                    mprColumn = c;
                }
                if (csv.data[r][c] == Options.engineSpeedColumnName) {
                    rpmColumn = c;
                }
            }
        } else {
            var mrp = csv.data[r][mprColumn];
            var rpm = csv.data[r][rpmColumn];
            if (isNaN(mrp) || isNaN(rpm)) {
                console.log("Weirdness")
            } else {
                var error = parseFloat(this.GetErrorForMrpRpm(mrp, rpm));
                csv.data[r][afLearningColumn] = (parseFloat(csv.data[r][afLearningColumn]) - error).toString();
            }
        }
    }

    this.MafScale(map, csv);
};

MafScaler.prototype.ToggleScaling = function(button) {
    this.smoothed = !this.smoothed;
    if (this.smoothed) {
        this.selectedMafTable = this.smoothedMafTable;
        $(button).html("No smoothing");
    } else {
        this.selectedMafTable = this.correctedMafTable;
        $(button).html("Smooth");
    }

    this.RenderMaf();
};

$(document).ready(function() {

    $("#fueling-error-scatter-chart-select").change(function() {
         GetMafScaler().RenderFuelingErrorScatterChart();
    });

    $("#save-maf").click(function(e) {
        e.preventDefault();
        GetMafScaler().UpdateMap();
        GetMapEdit().ClearRenderedTable();
    });

    $("#save-mrp-load-compensation").click(function(e) {
        e.preventDefault();
        GetMafScaler().UpdateMrpMap();
        GetMapEdit().ClearRenderedTable();
    });

    $("#smooth-maf").click(function(e) {
        e.preventDefault();
        GetMafScaler().ToggleScaling(this);
    });

    $("#apply-maf-corrections-to-logs").click(function(e) {
         e.preventDefault();
         GetMafScaler().UpdateAFLearing();
    });

    $("#apply-load-comp-corrections-to-logs").click(function(e) {
         e.preventDefault();
         GetMafScaler().UpdateAFLearingFromLoadComp();
    });
});


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MMMWrapper.Models
{
    public class M3Calendar
    {
        public int Company { get; set; }
        public string Division { get; set; }
        public DateTime DateYYYYMMDD { get; set; }
        public string DateUserDefined8 { get; set; }
        public string DateYYMMDD { get; set; }
        public string DateUserDefined6 { get; set; }
        public string DateDDMMYY { get; set; }
        public string DateMMDDYY { get; set; }
        public string DAteYYWWD { get; set; }
        public string DayNumberYYYYNNN { get; set; }
        public string WorkingDaySerialNumber { get; set; }
        public int GoodsReceivingDay { get; set; }
        public string GoodsReceivingDaySerialNumber { get; set; }
        public int DeliveryDay { get; set; }
        public string DeliveryDaySerialNumber { get; set; }
        public int BankDay { get; set; }
        public string BankDaySerialNumber { get; set; }
        public int ProductionDay { get; set; }
        public string WorkingDayPercentage { get; set; }
        public string DayNumber2YYYYNNN { get; set; }
        public string PeriodType1 { get; set; }
        public string PeriodType2 { get; set; }
        public string PeriodType3 { get; set; }
        public string PeriodType4 { get; set; }
        public string PeriodType5 { get; set; }
    }
}


text:
<?php

namespace GW2Treasures\GW2Api\V2\Endpoint\Pvp;

use GW2Treasures\GW2Api\GW2Api;
use GW2Treasures\GW2Api\V2\Authentication\AuthenticatedEndpoint;
use GW2Treasures\GW2Api\V2\Authentication\IAuthenticatedEndpoint;
use GW2Treasures\GW2Api\V2\Bulk\BulkEndpoint;
use GW2Treasures\GW2Api\V2\Bulk\IBulkEndpoint;
use GW2Treasures\GW2Api\V2\Endpoint;

class GameEndpoint extends Endpoint implements IAuthenticatedEndpoint, IBulkEndpoint {
    use AuthenticatedEndpoint, BulkEndpoint;

    /**
     * @param GW2Api $api
     * @param string $apiKey
     */
    public function __construct(GW2Api $api, $apiKey) {
        $this->apiKey = $apiKey;

        parent::__construct($api);
    }

    /**
     * The url of this endpoint.
     *
     * @return string
     */
    public function url() {
        return 'v2/pvp/games';
    }
}


text:
<?php

class paymill_payment extends paymill_payment_parent
{
    private $_fastCheckoutData;

    private $_payments;

    private $_payment;

    /**
     * Rewrite of oxid's getPaymentList method
     * adds some errors to the payment selection if necessary
     *
     * @overload
     */
    public function render()
    {
        $oxConfig = oxConfig::getInstance();
        // @TODO verify if fastcheckout-data should only be set if fastcheckout is active
        // @TODO see if we need the request without verifying if fastCheckoutData exists
        if ($this->getUser() && $this->_isFastCheckoutAllowed()) {
            $this->_payments = new Services_Paymill_Payments(
                trim($oxConfig->getShopConfVar('PAYMILL_PRIVATEKEY')),
                paymill_util::API_ENDPOINT
            );

            $this->_fastCheckoutData = oxNew('paymill_fastcheckout');
            $this->_fastCheckoutData->load($this->getUser()->getId());

            $this->_setPayment(
                $this->_fastCheckoutData->paymill_fastcheckout__paymentid_cc->rawValue
            );
            if (array_key_exists('last4', $this->_payment)) {
                $this->addTplParam('fastCheckoutCc', 'true');
                $this->_setPaymillCcPaymentData();
            } else {
                $this->addTplParam('fastCheckoutCc', 'false');
            }

            $this->_setPayment(
                $this->_fastCheckoutData->paymill_fastcheckout__paymentid_elv->rawValue
            );

            if (array_key_exists('account', $this->_payment) || array_key_exists('iban', $this->_payment)) {
                $this->addTplParam('fastCheckoutElv', 'true');
                $this->_setPaymillElvPaymentData();
            } else {
                $this->addTplParam('fastCheckoutElv', 'false');
            }
        } else {
            $this->addTplParam('fastCheckoutCc', 'false');
            $this->addTplParam('fastCheckoutElv', 'false');
        }

        $this->addTplParam(
            'paymillPublicKey',
            trim($oxConfig->getShopConfVar('PAYMILL_PUBLICKEY'))
        );

        $this->addTplParam(
            'paymillUtil',
            oxNew('paymill_util')
        );

        $this->_addToTplWhichCreditCardsToShow();

        $this->addTplParam(
            'paymillCompliance',
            $oxConfig->getShopConfVar('PAYMILL_COMPLIANCE')
        );

        return parent::render();
    }

    private function _setPayment($paymentId)
    {
        $this->_payment = $this->_payments->getOne(
            $paymentId
        );

        if (is_null($this->_payment)) {
            $this->_payment = array();
        }
    }

    private function _setPaymillCcPaymentData()
    {
        if (!array_key_exists('error', $this->_payment)) {
            $this->addTplParam('paymillCcLastFour', '************' . $this->_getEntry($this->_payment, 'last4'));
            $this->addTplParam('paymillCcCvc', '***');
            $this->addTplParam('paymillCcCardHolder', $this->_getEntry($this->_payment, 'card_holder'));
            $this->addTplParam('paymillCcExpireMonth', $this->_getEntry($this->_payment, 'expire_month'));
            $this->addTplParam('paymillCcExpireYear', $this->_getEntry($this->_payment, 'expire_year'));
            if ($this->_getEntry($this->_payment, 'card_type') === 'american express') {
                $this->addTplParam('brand', 'amex');
            } else {
                $this->addTplParam('brand', $this->_getEntry($this->_payment, 'card_type'));
            }
        }
    }

    private function _setPaymillElvPaymentData()
    {
        if (!array_key_exists('error', $this->_payment)) {
            $this->addTplParam('paymillElvHolder', $this->_getEntry($this->_payment, 'holder'));

            $fastCheckoutAccount = $this->_getEntry($this->_payment, 'account');
            $fastCheckoutCode = $this->_getEntry($this->_payment, 'code');
            $fastCheckoutIban = $this->_getEntry($this->_payment, 'iban');
            $fastCheckoutBic = $this->_getEntry($this->_payment, 'bic');

            if (is_null($fastCheckoutIban) && !is_null($fastCheckoutAccount) && !is_null($fastCheckoutCode)) {
                $account = $fastCheckoutAccount;
                $code = $fastCheckoutCode;
            } else {
                $account = $fastCheckoutIban;
                $code = $fastCheckoutBic;
            }

            $this->addTplParam('paymillElvAccount', $account);
            $this->addTplParam('paymillElvCode', $code);
        }
    }

    private function _getEntry($data, $key)
    {
        if (!is_array($data)) {
            $data = array();
        }

        return array_key_exists($key, $data) ? $data[$key] : null;
    }

    /**
     * loads the paymentlist
     *
     * @overload
     */
    public function getPaymentList()
    {
        //clear values
        oxSession::deleteVar('paymill_authorized_amount');
        $differentAmount = intval(round(oxConfig::getInstance()->getShopConfVar('PAYMILL_ACTIVATE_DIFFERENTAMOUNT'), 2) * 100);
        //save authorized Amount for secure Paymentprocessing
        $amount = intval(round(oxSession::getInstance()->getBasket()->getPrice()->getBruttoPrice() * 100) + $differentAmount);
        oxSession::setVar('paymill_authorized_amount', $amount);
        $this->addTplParam('paymillAmount', $amount);

        $paymentList = parent::getPaymentList();

        $privateKey = oxConfig::getInstance()->getShopConfVar('PAYMILL_PRIVATEKEY');
        $publicKey  = oxConfig::getInstance()->getShopConfVar('PAYMILL_PUBLICKEY');

        if (empty($privateKey) || empty($publicKey)) {
            // @TODO log message so user knows that payment was deactivated because of missing private or public key
            unset($paymentList['paymill_elv']);
            unset($paymentList['paymill_cc']);
        }

        return $paymentList;
    }

    /**
     * @overload
     */
    public function validatePayment()
    {
        if (oxConfig::getParameter('paymentid') === "paymill_cc" || oxConfig::getParameter('paymentid') === "paymill_elv") {
            oxSession::deleteVar('paymill_token');
            // set paymill token to session to be available in next step
            if (oxConfig::getParameter('paymillToken')) {
                oxSession::setVar('paymill_token', oxConfig::getParameter('paymillToken'));
            }
        }

        return parent::validatePayment();
    }

    private function _addToTplWhichCreditCardsToShow()
    {
        $settings = array(
            'visa' => oxConfig::getInstance()->getShopConfVar('PAYMILL_VISA'),
            'mastercard' => oxConfig::getInstance()->getShopConfVar('PAYMILL_MASTERCARD'),
            'amex' => oxConfig::getInstance()->getShopConfVar('PAYMILL_AMEX'),
            'carta-si' => oxConfig::getInstance()->getShopConfVar('PAYMILL_CARTA_SI'),
            'carte-bleue' => oxConfig::getInstance()->getShopConfVar('PAYMILL_CARTE_BLEUE'),
            'diners-club' => oxConfig::getInstance()->getShopConfVar('PAYMILL_DINERSCLUB'),
            'jcb' => oxConfig::getInstance()->getShopConfVar('PAYMILL_JCB'),
            'maestro' => oxConfig::getInstance()->getShopConfVar('PAYMILL_MAESTRO'),
            'china-unionpay' => oxConfig::getInstance()->getShopConfVar('PAYMILL_UNIONPAY'),
            'discover' => oxConfig::getInstance()->getShopConfVar('PAYMILL_DISCOVER'),
            'dankort' => oxConfig::getInstance()->getShopConfVar('PAYMILL_DANKORT')
        );

        $ccToShow = array();

        foreach ($settings as $card => $setting) {
            if ($setting) {
                array_push($ccToShow, $card);
            }
        }

        $this->addTplParam('paymillBrands', $ccToShow);
    }

    /**
     * Get module settings for fast checkout
     * @return boolean is fast checkout active
     */
    public function _isFastCheckoutAllowed()
    {
        $isFastCheckoutActive = oxConfig::getInstance()->getShopConfVar(
            'PAYMILL_ACTIVATE_FASTCHECKOUT'
        );

        return $isFastCheckoutActive;
    }

}


text:
/** @constructor */
ScalaJS.c.scala_collection_concurrent_LNode = (function() {
  ScalaJS.c.scala_collection_concurrent_MainNode.call(this);
  this.listmap$3 = null
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype = new ScalaJS.inheritable.scala_collection_concurrent_MainNode();
ScalaJS.c.scala_collection_concurrent_LNode.prototype.constructor = ScalaJS.c.scala_collection_concurrent_LNode;
ScalaJS.c.scala_collection_concurrent_LNode.prototype.listmap__Lscala_collection_immutable_ListMap = (function() {
  return this.listmap$3
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.inserted__O__O__Lscala_collection_concurrent_LNode = (function(k, v) {
  return new ScalaJS.c.scala_collection_concurrent_LNode().init___Lscala_collection_immutable_ListMap(this.listmap__Lscala_collection_immutable_ListMap().$$plus__Lscala_Tuple2__Lscala_collection_immutable_ListMap(new ScalaJS.c.scala_Tuple2().init___O__O(k, v)))
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.removed__O__Lscala_collection_concurrent_TrieMap__Lscala_collection_concurrent_MainNode = (function(k, ct) {
  var updmap = this.listmap__Lscala_collection_immutable_ListMap().$$minus__O__Lscala_collection_immutable_ListMap(k);
  if ((updmap.size__I() > 1)) {
    return new ScalaJS.c.scala_collection_concurrent_LNode().init___Lscala_collection_immutable_ListMap(updmap)
  } else {
    var x1 = ScalaJS.as.scala_Tuple2(updmap.iterator__Lscala_collection_Iterator().next__O());
    matchEnd3: {
      if ((x1 !== null)) {
        var k$2 = x1.$$und1__O();
        var v = x1.$$und2__O();
        var x$1 = new ScalaJS.c.scala_Tuple2().init___O__O(k$2, v);
        break matchEnd3
      };
      throw new ScalaJS.c.scala_MatchError().init___O(x1)
    };
    var k$3 = x$1.$$und1__O();
    var v$2 = x$1.$$und2__O();
    return new ScalaJS.c.scala_collection_concurrent_TNode().init___O__O__I(k$3, v$2, ct.computeHash__O__I(k$3))
  }
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.get__O__Lscala_Option = (function(k) {
  return this.listmap__Lscala_collection_immutable_ListMap().get__O__Lscala_Option(k)
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.cachedSize__O__I = (function(ct) {
  return this.listmap__Lscala_collection_immutable_ListMap().size__I()
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.string__I__T = (function(lev) {
  return (("" + new ScalaJS.c.scala_collection_immutable_StringOps().init___T(ScalaJS.modules.scala_Predef().augmentString__T__T(" ")).$$times__I__T(lev)) + new ScalaJS.c.scala_collection_immutable_StringOps().init___T(ScalaJS.modules.scala_Predef().augmentString__T__T("LNode(%s)")).format__Lscala_collection_Seq__T(ScalaJS.modules.scala_Predef().genericWrapArray__O__Lscala_collection_mutable_WrappedArray(ScalaJS.makeNativeArrayWrapper(ScalaJS.data.java_lang_Object.getArrayOf(), [this.listmap__Lscala_collection_immutable_ListMap().mkString__T__T(", ")]))))
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.init___Lscala_collection_immutable_ListMap = (function(listmap) {
  this.listmap$3 = listmap;
  ScalaJS.c.scala_collection_concurrent_MainNode.prototype.init___.call(this);
  return this
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.init___O__O = (function(k, v) {
  ScalaJS.c.scala_collection_concurrent_LNode.prototype.init___Lscala_collection_immutable_ListMap.call(this, ScalaJS.as.scala_collection_immutable_ListMap(ScalaJS.modules.scala_collection_immutable_ListMap().apply__Lscala_collection_Seq__Lscala_collection_GenMap(ScalaJS.modules.scala_Predef().wrapRefArray__AO__Lscala_collection_mutable_WrappedArray(ScalaJS.asArrayOf.java_lang_Object(ScalaJS.makeNativeArrayWrapper(ScalaJS.data.scala_Tuple2.getArrayOf(), [ScalaJS.modules.scala_Predef$ArrowAssoc().$$minus$greater$extension__O__O__Lscala_Tuple2(ScalaJS.modules.scala_Predef().any2ArrowAssoc__O__O(k), v)]), 1)))));
  return this
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.init___O__O__O__O = (function(k1, v1, k2, v2) {
  ScalaJS.c.scala_collection_concurrent_LNode.prototype.init___Lscala_collection_immutable_ListMap.call(this, ScalaJS.as.scala_collection_immutable_ListMap(ScalaJS.modules.scala_collection_immutable_ListMap().apply__Lscala_collection_Seq__Lscala_collection_GenMap(ScalaJS.modules.scala_Predef().wrapRefArray__AO__Lscala_collection_mutable_WrappedArray(ScalaJS.asArrayOf.java_lang_Object(ScalaJS.makeNativeArrayWrapper(ScalaJS.data.scala_Tuple2.getArrayOf(), [ScalaJS.modules.scala_Predef$ArrowAssoc().$$minus$greater$extension__O__O__Lscala_Tuple2(ScalaJS.modules.scala_Predef().any2ArrowAssoc__O__O(k1), v1), ScalaJS.modules.scala_Predef$ArrowAssoc().$$minus$greater$extension__O__O__Lscala_Tuple2(ScalaJS.modules.scala_Predef().any2ArrowAssoc__O__O(k2), v2)]), 1)))));
  return this
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.get__O__ = (function(k) {
  return this.get__O__Lscala_Option(k)
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.removed__O__Lscala_collection_concurrent_TrieMap__ = (function(k$2, ct) {
  return this.removed__O__Lscala_collection_concurrent_TrieMap__Lscala_collection_concurrent_MainNode(k$2, ct)
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.inserted__O__O__ = (function(k$3, v) {
  return this.inserted__O__O__Lscala_collection_concurrent_LNode(k$3, v)
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.listmap__ = (function() {
  return this.listmap__Lscala_collection_immutable_ListMap()
});
/** @constructor */
ScalaJS.inheritable.scala_collection_concurrent_LNode = (function() {
  /*<skip>*/
});
ScalaJS.inheritable.scala_collection_concurrent_LNode.prototype = ScalaJS.c.scala_collection_concurrent_LNode.prototype;
ScalaJS.is.scala_collection_concurrent_LNode = (function(obj) {
  return (!(!((obj && obj.$classData) && obj.$classData.ancestors.scala_collection_concurrent_LNode)))
});
ScalaJS.as.scala_collection_concurrent_LNode = (function(obj) {
  if ((ScalaJS.is.scala_collection_concurrent_LNode(obj) || (obj === null))) {
    return obj
  } else {
    ScalaJS.throwClassCastException(obj, "scala.collection.concurrent.LNode")
  }
});
ScalaJS.isArrayOf.scala_collection_concurrent_LNode = (function(obj, depth) {
  return (!(!(((obj && obj.$classData) && (obj.$classData.arrayDepth === depth)) && obj.$classData.arrayBase.ancestors.scala_collection_concurrent_LNode)))
});
ScalaJS.asArrayOf.scala_collection_concurrent_LNode = (function(obj, depth) {
  if ((ScalaJS.isArrayOf.scala_collection_concurrent_LNode(obj, depth) || (obj === null))) {
    return obj
  } else {
    ScalaJS.throwArrayCastException(obj, "Lscala.collection.concurrent.LNode;", depth)
  }
});
ScalaJS.data.scala_collection_concurrent_LNode = new ScalaJS.ClassTypeData({
  scala_collection_concurrent_LNode: 0
}, false, "scala.collection.concurrent.LNode", ScalaJS.data.scala_collection_concurrent_MainNode, {
  scala_collection_concurrent_LNode: 1,
  scala_collection_concurrent_MainNode: 1,
  scala_collection_concurrent_BasicNode: 1,
  java_lang_Object: 1
});
ScalaJS.c.scala_collection_concurrent_LNode.prototype.$classData = ScalaJS.data.scala_collection_concurrent_LNode;
//@ sourceMappingURL=LNode.js.map