text:
if select(2, UnitClass("player")) ~= "HUNTER" then
	do return end
end

StayFocused_HunterHelper = CreateFrame("Frame")
local frame = StayFocused_HunterHelper

frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("UNIT_POWER")
frame:RegisterEvent("UNIT_SPELLCAST_START")
frame:RegisterEvent("UNIT_SPELLCAST_STOP")
frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
frame:RegisterEvent("UNIT_SPELLCAST_FAILED")

StayFocused_HunterHelper_Cast = CreateFrame("StatusBar", nil, StayFocused)
local precast = StayFocused_HunterHelper_Cast

StayFocused_HunterHelper_Spark = CreateFrame("Frame", nil, StayFocused)
local spark = StayFocused_HunterHelper_Spark

local sparkmin = spark:CreateTexture(nil,"OVERLAY");
sparkmin:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark");

local sparkmax = spark:CreateTexture(nil,"OVERLAY");
sparkmax:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark");

local function precast_Hide()
	precast:SetAlpha(0)
end

local function precast_Show()
	 precast:SetAlpha(StayFocused:GetAlpha()*0.5)
end

local function SpellInfo(spell)
	local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spell)
	return name, cost
end

local function MainShot()

	local tree = GetPrimaryTalentTree()

	if tree == 3 then
		return select(2, SpellInfo(53301)), 53301
	elseif tree == 2 then
		return select(2, SpellInfo(53209)), 53209
	else
		return select(2, SpellInfo(34026)), 34026
	end

end

local _, dumpshot = SpellInfo(SpellInfo(3044))
local mainshot = MainShot()
local regen = GetPowerRegen()

local function precast_Set()
   local alias = StayFocused
   local db = StayFocused_HunterHelperDB

   precast:SetStatusBarTexture(StayFocused:GetStatusBarTexture():GetTexture())
   precast:SetMinMaxValues(0, 1)
   precast:SetValue(1)
   precast:SetFrameLevel(alias:GetFrameLevel())

   precast:SetSize((alias:GetWidth()/100)*9, alias:GetHeight())

   precast_Hide()

	if frame.db.castcolor then
		precast:SetStatusBarColor(db.precolor[1], db.precolor[2], db.precolor[3], 1)
	else
		precast:SetStatusBarColor(StayFocused:GetStatusBarColor())
	end
end

local include = 0
local casting = false
local function precast_Update()

	if not casting then return end

	local alias = StayFocused

	local width = alias:GetWidth()
	local value = alias:GetValue()
	local _, max = alias:GetMinMaxValues()
	local position = width/(max/value)

	if UnitHealth("target")/UnitHealthMax("target") <= 0.25 then
		include = 9 + select(5, GetTalentInfo(2, 12)) * 3
	end

--	precast:SetSize((alias:GetWidth()/100)*(include or 9), alias:GetHeight())
	precast:SetSize((alias:GetWidth()/100)*(include), alias:GetHeight())

	precast:ClearAllPoints()
	precast:SetPoint("LEFT", alias, "LEFT", position, 0)
	if not frame.db.castcolor then
		precast:SetStatusBarColor(StayFocused:GetStatusBarColor())
	end

end

local function spark_Set()

	if not frame.db.show_spark then
		sparkmin:Hide()
		sparkmax:Hide()
		return
	end

	local alias = StayFocused
	sparkmin:SetWidth(10)
    sparkmin:SetBlendMode("ADD")
    sparkmin:SetHeight(alias:GetHeight()*1.7)

	sparkmax:SetWidth(10)
    sparkmax:SetBlendMode("ADD")
    sparkmax:SetHeight(alias:GetHeight()*1.7)
end

local function spark_Update(power)

	if not frame.db.show_spark then
		sparkmin:Hide()
		sparkmax:Hide()
		return
	end

	local alias = StayFocused
	local _, mainshot_id = MainShot()
	local power = power or 0

 	local width = alias:GetWidth()
	local _, max = alias:GetMinMaxValues()
	local ppf = (width/max)

	do
		if mainshot == 0 then return end -- to avoid lock + load confusion
		sparkmin:SetPoint("LEFT", alias, "LEFT", mainshot*ppf-5, 0)
		sparkmax:SetPoint("LEFT", alias, "LEFT", (mainshot+dumpshot)*ppf-5, 0)
	end

	local start, duration, enabled = GetSpellCooldown(mainshot_id)
	if ( start > 0 and duration > 0) then
		local cooldown = (start + duration - GetTime())
		if cooldown > 3 then
			sparkmin:SetVertexColor(1,0,0) -- not ready
		elseif cooldown > 1 then
			sparkmin:SetVertexColor(1,0.5,0) -- ready soon
		else
			sparkmin:SetVertexColor(0.5,1,0) --gcd, ready
		end
	else
	 sparkmin:SetVertexColor(0,1,0) --no gcd, ready
	end

	if power >= select(2, SpellInfo(2643)) then
		sparkmax:SetVertexColor(0,1,0)
	else
		sparkmax:SetVertexColor(1,1,0)
	end

	sparkmin:Show()
	sparkmax:Show()
end

function frame:ApplyOptions()
	precast_Set()
	spark_Set()
end

--fps calculation
local pow_c = 0
local array_pairs = {}
local array_time = {}
local pointer = 1
local timer = 0
local function HunterHelperCalc(power, max_power, elapsed)

   if power == max_power then
      do return end
   end

   timer = timer + elapsed

      local pow = UnitPower("player")

      if pointer > 3 then pointer = 1 end

      if pow_c ~= pow then
         if ((pow-pow_c) > 1) and ((pow-pow_c) < 9 )then
            array_pairs[pointer] = {pow-pow_c, 6*timer}
			timer = 0
            local sum_f = 0
            local sum_t = 0
            local size = 0

            for k,v in pairs(array_pairs) do
			   size = k
               sum_f = sum_f + v[1]
               sum_t = sum_t + v[2]
            end

            local avg_f = sum_f / size
            local avg_t = sum_t / size
            array_time[pointer] = avg_f/avg_t
            local sum_b = 0
            local size_b = 0

            for k,v in pairs(array_time) do
			   size_b = k
               sum_b = sum_b + v
            end

            regen = GetPowerRegen() + (sum_b/size_b)
            pointer = pointer + 1
         end
         pow_c = pow
      end
	 -- regen = 4
end

local function HunterHelperOnUpdate(power, max_power, elapsed)

	if not frame.db.include_ss then include = 0 end

	HunterHelperCalc(power, max_power, elapsed)
	local color = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
	_, dumpshot = SpellInfo(SpellInfo(3044))
	mainshot = MainShot()
		--color handling
	if mainshot then
		if power > mainshot + dumpshot - regen - include then
		--if power > 75 then
			StayFocused:SetStatusBarColor(frame.db.fullcolor[1], frame.db.fullcolor[2], frame.db.fullcolor[3])
		elseif power < mainshot - include then
		--elseif power < 40 then
			StayFocused:SetStatusBarColor(frame.db.warncolor[1], frame.db.warncolor[2], frame.db.warncolor[3])
		elseif StayFocusedDB["class_colored"] == true then
			StayFocused:SetStatusBarColor(color.r, color.g, color.b)
		else
			StayFocused:SetStatusBarColor(1,1,1)
		end
		spark_Update(power)
	end

		--value handling
	if frame.db.show_text and StayFocused.value:GetText() then

		local value = StayFocused.value:GetText()
		value = value .. " (~" .. string.format("%.1f", regen) .. " f/s )"
		StayFocused.value:SetText(value)
	end
		--precast
	if  frame.db.show_cast then

		precast_Update()
	end
end

--frame:SetScript("OnUpdate", HunterHelperOnUpdateTimer)

frame:SetScript("OnEvent", function(self, event, ...)
	local steady = 56641
	local cobra = 77767
		if event == "ADDON_LOADED" then
			local addon = ...
			if addon:lower() ~= "stayfocused_hunterhelper" then return end

			if StayFocused_HunterHelperDB then
				if StayFocused_HunterHelperDB.show_cast == nil then StayFocused_HunterHelperDB = nil end -- 400002.3 to 40000.3 reset
				if StayFocused_HunterHelperDB.include_ss == nil then StayFocused_HunterHelperDB.include_ss = true end --40000.5.1 to 40000.5.2
				if StayFocused_HunterHelperDB.castcolor == nil then StayFocused_HunterHelperDB.castcolor = false end --40000.5.1 to 40000.5.2
				if StayFocused_HunterHelperDB.warncolor == nil then StayFocused_HunterHelperDB = nil end --40000.5.2 to 40000.5.3 reset
				if StayFocused_HunterHelperDB.show_spark == nil then StayFocused_HunterHelperDB.show_spark = true end --40000.6.2 to 40000.6.3
			end

			StayFocused_HunterHelperDB = StayFocused_HunterHelperDB or {
				show_text = false,
				show_cast = true,
				warncolor = {1, 0.3, 0.2},
				fullcolor = {0, 0.3, 1},
				precolor = {0, 1, 0.4},
				include_ss = true,
				castcolor = false,
				show_spark = true,
			}

			self.db = StayFocused_HunterHelperDB

			StayFocused:AddHandler('HunterHelper', HunterHelperOnUpdate)
			hooksecurefunc(StayFocused, "ApplyOptions", precast_Set)
			hooksecurefunc(StayFocused, "ApplyOptions", spark_Set)

			self:UnregisterEvent("ADDON_LOADED")

			precast_Set()
			precast_Hide()
			spark_Set()
	elseif event == "UNIT_SPELLCAST_START" then
		if select(1, ...) == "player" then
			local spellid = select(5, ...)
			if spellid  == steady or spellid == cobra then
				include = 9
				casting = true
				if self.db.show_cast then
					precast_Update()
					precast_Show()
				end
			end
		end
	elseif string.find(event, "UNIT_SPELLCAST_") then
		if select(1, ...) == "player" then
			local spellid = select(5, ...)
			if spellid  == steady or spellid == cobra then
				include = 0
				casting = false
				if self.db.show_cast then
					precast_Hide()
				end
			end
		end
	end
end)


text:
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });

function preload() {

	game.load.spritesheet('spinner', 'assets/sprites/bluemetal_32x32x4.png', 32, 32);

}

var sprites;

function create() {

	//	Here we create a group, populate it with sprites, give them all a random velocity
	//	and then check the group against itself for collision

	sprites = game.add.physicsGroup(Phaser.Physics.ARCADE);

	for (var i = 0; i < 90; i++)
	{
		var s = sprites.create(game.rnd.integerInRange(100, 700), game.rnd.integerInRange(32, 200), 'spinner');
		s.animations.add('spin', [0, 1, 2, 3]);
		s.play('spin', 20, true);
		s.body.velocity.set(game.rnd.integerInRange(-200, 200), game.rnd.integerInRange(-200, 200));
	}

	sprites.setAll('body.collideWorldBounds', true);
	sprites.setAll('body.bounce.x', 1);
	sprites.setAll('body.bounce.y', 1);

}

function update() {

	game.physics.arcade.collide(sprites);

}

redpajama_set_name: RedPajamaGithub


text:
/*
 * CSE1_HIL_u.h
 *
 * Code generation for model "CSE1_HIL_u".
 *
 * Model version              : 1.22
 * Simulink Coder version : 8.6 (R2014a) 27-Dec-2013
 * C source code generated on : Tue Mar 24 14:41:05 2015
 *
 * Target selection: NIVeriStand_VxWorks.tlc
 * Note: GRT includes extra infrastructure and instrumentation for prototyping
 * Embedded hardware selection: 32-bit Generic
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */
#ifndef RTW_HEADER_CSE1_HIL_u_h_
#define RTW_HEADER_CSE1_HIL_u_h_
#include <math.h>
#include <string.h>
#include <stddef.h>
#ifndef CSE1_HIL_u_COMMON_INCLUDES_
# define CSE1_HIL_u_COMMON_INCLUDES_
#include "rtwtypes.h"
#include "simstruc.h"
#include "fixedpoint.h"
#include "rt_logging.h"
#endif                                 /* CSE1_HIL_u_COMMON_INCLUDES_ */

#include "CSE1_HIL_u_types.h"

/* Shared type includes */
#include "multiword_types.h"
#include "rt_zcfcn.h"
#include "rt_defines.h"
#include "rt_nonfinite.h"

/* Macros for accessing real-time model data structure */
#ifndef rtmGetBlkStateChangeFlag
# define rtmGetBlkStateChangeFlag(rtm) ((rtm)->ModelData.blkStateChange)
#endif

#ifndef rtmSetBlkStateChangeFlag
# define rtmSetBlkStateChangeFlag(rtm, val) ((rtm)->ModelData.blkStateChange = (val))
#endif

#ifndef rtmGetBlockIO
# define rtmGetBlockIO(rtm)            ((rtm)->ModelData.blockIO)
#endif

#ifndef rtmSetBlockIO
# define rtmSetBlockIO(rtm, val)       ((rtm)->ModelData.blockIO = (val))
#endif

#ifndef rtmGetChecksums
# define rtmGetChecksums(rtm)          ((rtm)->Sizes.checksums)
#endif

#ifndef rtmSetChecksums
# define rtmSetChecksums(rtm, val)     ((rtm)->Sizes.checksums = (val))
#endif

#ifndef rtmGetConstBlockIO
# define rtmGetConstBlockIO(rtm)       ((rtm)->ModelData.constBlockIO)
#endif

#ifndef rtmSetConstBlockIO
# define rtmSetConstBlockIO(rtm, val)  ((rtm)->ModelData.constBlockIO = (val))
#endif

#ifndef rtmGetContStateDisabled
# define rtmGetContStateDisabled(rtm)  ((rtm)->ModelData.contStateDisabled)
#endif

#ifndef rtmSetContStateDisabled
# define rtmSetContStateDisabled(rtm, val) ((rtm)->ModelData.contStateDisabled = (val))
#endif

#ifndef rtmGetContStates
# define rtmGetContStates(rtm)         ((rtm)->ModelData.contStates)
#endif

#ifndef rtmSetContStates
# define rtmSetContStates(rtm, val)    ((rtm)->ModelData.contStates = (val))
#endif

#ifndef rtmGetDataMapInfo
# define rtmGetDataMapInfo(rtm)        ()
#endif

#ifndef rtmSetDataMapInfo
# define rtmSetDataMapInfo(rtm, val)   ()
#endif

#ifndef rtmGetDefaultParam
# define rtmGetDefaultParam(rtm)       ((rtm)->ModelData.defaultParam)
#endif

#ifndef rtmSetDefaultParam
# define rtmSetDefaultParam(rtm, val)  ((rtm)->ModelData.defaultParam = (val))
#endif

#ifndef rtmGetDerivCacheNeedsReset
# define rtmGetDerivCacheNeedsReset(rtm) ((rtm)->ModelData.derivCacheNeedsReset)
#endif

#ifndef rtmSetDerivCacheNeedsReset
# define rtmSetDerivCacheNeedsReset(rtm, val) ((rtm)->ModelData.derivCacheNeedsReset = (val))
#endif

#ifndef rtmGetDirectFeedThrough
# define rtmGetDirectFeedThrough(rtm)  ((rtm)->Sizes.sysDirFeedThru)
#endif

#ifndef rtmSetDirectFeedThrough
# define rtmSetDirectFeedThrough(rtm, val) ((rtm)->Sizes.sysDirFeedThru = (val))
#endif

#ifndef rtmGetErrorStatusFlag
# define rtmGetErrorStatusFlag(rtm)    ((rtm)->errorStatus)
#endif

#ifndef rtmSetErrorStatusFlag
# define rtmSetErrorStatusFlag(rtm, val) ((rtm)->errorStatus = (val))
#endif

#ifndef rtmGetFinalTime
# define rtmGetFinalTime(rtm)          ((rtm)->Timing.tFinal)
#endif

#ifndef rtmSetFinalTime
# define rtmSetFinalTime(rtm, val)     ((rtm)->Timing.tFinal = (val))
#endif

#ifndef rtmGetFirstInitCondFlag
# define rtmGetFirstInitCondFlag(rtm)  ((rtm)->Timing.firstInitCondFlag)
#endif

#ifndef rtmSetFirstInitCondFlag
# define rtmSetFirstInitCondFlag(rtm, val) ((rtm)->Timing.firstInitCondFlag = (val))
#endif

#ifndef rtmGetIntgData
# define rtmGetIntgData(rtm)           ((rtm)->ModelData.intgData)
#endif

#ifndef rtmSetIntgData
# define rtmSetIntgData(rtm, val)      ((rtm)->ModelData.intgData = (val))
#endif

#ifndef rtmGetMdlRefGlobalTID
# define rtmGetMdlRefGlobalTID(rtm)    ()
#endif

#ifndef rtmSetMdlRefGlobalTID
# define rtmSetMdlRefGlobalTID(rtm, val) ()
#endif

#ifndef rtmGetMdlRefTriggerTID
# define rtmGetMdlRefTriggerTID(rtm)   ()
#endif

#ifndef rtmSetMdlRefTriggerTID
# define rtmSetMdlRefTriggerTID(rtm, val) ()
#endif

#ifndef rtmGetModelMappingInfo
# define rtmGetModelMappingInfo(rtm)   ((rtm)->SpecialInfo.mappingInfo)
#endif

#ifndef rtmSetModelMappingInfo
# define rtmSetModelMappingInfo(rtm, val) ((rtm)->SpecialInfo.mappingInfo = (val))
#endif

#ifndef rtmGetModelName
# define rtmGetModelName(rtm)          ((rtm)->modelName)
#endif

#ifndef rtmSetModelName
# define rtmSetModelName(rtm, val)     ((rtm)->modelName = (val))
#endif

#ifndef rtmGetNonInlinedSFcns
# define rtmGetNonInlinedSFcns(rtm)    ()
#endif

#ifndef rtmSetNonInlinedSFcns
# define rtmSetNonInlinedSFcns(rtm, val) ()
#endif

#ifndef rtmGetNumBlockIO
# define rtmGetNumBlockIO(rtm)         ((rtm)->Sizes.numBlockIO)
#endif

#ifndef rtmSetNumBlockIO
# define rtmSetNumBlockIO(rtm, val)    ((rtm)->Sizes.numBlockIO = (val))
#endif

#ifndef rtmGetNumBlockParams
# define rtmGetNumBlockParams(rtm)     ((rtm)->Sizes.numBlockPrms)
#endif

#ifndef rtmSetNumBlockParams
# define rtmSetNumBlockParams(rtm, val) ((rtm)->Sizes.numBlockPrms = (val))
#endif

#ifndef rtmGetNumBlocks
# define rtmGetNumBlocks(rtm)          ((rtm)->Sizes.numBlocks)
#endif

#ifndef rtmSetNumBlocks
# define rtmSetNumBlocks(rtm, val)     ((rtm)->Sizes.numBlocks = (val))
#endif

#ifndef rtmGetNumContStates
# define rtmGetNumContStates(rtm)      ((rtm)->Sizes.numContStates)
#endif

#ifndef rtmSetNumContStates
# define rtmSetNumContStates(rtm, val) ((rtm)->Sizes.numContStates = (val))
#endif

#ifndef rtmGetNumDWork
# define rtmGetNumDWork(rtm)           ((rtm)->Sizes.numDwork)
#endif

#ifndef rtmSetNumDWork
# define rtmSetNumDWork(rtm, val)      ((rtm)->Sizes.numDwork = (val))
#endif

#ifndef rtmGetNumInputPorts
# define rtmGetNumInputPorts(rtm)      ((rtm)->Sizes.numIports)
#endif

#ifndef rtmSetNumInputPorts
# define rtmSetNumInputPorts(rtm, val) ((rtm)->Sizes.numIports = (val))
#endif

#ifndef rtmGetNumNonSampledZCs
# define rtmGetNumNonSampledZCs(rtm)   ((rtm)->Sizes.numNonSampZCs)
#endif

#ifndef rtmSetNumNonSampledZCs
# define rtmSetNumNonSampledZCs(rtm, val) ((rtm)->Sizes.numNonSampZCs = (val))
#endif

#ifndef rtmGetNumOutputPorts
# define rtmGetNumOutputPorts(rtm)     ((rtm)->Sizes.numOports)
#endif

#ifndef rtmSetNumOutputPorts
# define rtmSetNumOutputPorts(rtm, val) ((rtm)->Sizes.numOports = (val))
#endif

#ifndef rtmGetNumSFcnParams
# define rtmGetNumSFcnParams(rtm)      ((rtm)->Sizes.numSFcnPrms)
#endif

#ifndef rtmSetNumSFcnParams
# define rtmSetNumSFcnParams(rtm, val) ((rtm)->Sizes.numSFcnPrms = (val))
#endif

#ifndef rtmGetNumSFunctions
# define rtmGetNumSFunctions(rtm)      ((rtm)->Sizes.numSFcns)
#endif

#ifndef rtmSetNumSFunctions
# define rtmSetNumSFunctions(rtm, val) ((rtm)->Sizes.numSFcns = (val))
#endif

#ifndef rtmGetNumSampleTimes
# define rtmGetNumSampleTimes(rtm)     ((rtm)->Sizes.numSampTimes)
#endif

#ifndef rtmSetNumSampleTimes
# define rtmSetNumSampleTimes(rtm, val) ((rtm)->Sizes.numSampTimes = (val))
#endif

#ifndef rtmGetNumU
# define rtmGetNumU(rtm)               ((rtm)->Sizes.numU)
#endif

#ifndef rtmSetNumU
# define rtmSetNumU(rtm, val)          ((rtm)->Sizes.numU = (val))
#endif

#ifndef rtmGetNumY
# define rtmGetNumY(rtm)               ((rtm)->Sizes.numY)
#endif

#ifndef rtmSetNumY
# define rtmSetNumY(rtm, val)          ((rtm)->Sizes.numY = (val))
#endif

#ifndef rtmGetOdeF
# define rtmGetOdeF(rtm)               ((rtm)->ModelData.odeF)
#endif

#ifndef rtmSetOdeF
# define rtmSetOdeF(rtm, val)          ((rtm)->ModelData.odeF = (val))
#endif

#ifndef rtmGetOdeY
# define rtmGetOdeY(rtm)               ((rtm)->ModelData.odeY)
#endif

#ifndef rtmSetOdeY
# define rtmSetOdeY(rtm, val)          ((rtm)->ModelData.odeY = (val))
#endif

#ifndef rtmGetOffsetTimeArray
# define rtmGetOffsetTimeArray(rtm)    ((rtm)->Timing.offsetTimesArray)
#endif

#ifndef rtmSetOffsetTimeArray
# define rtmSetOffsetTimeArray(rtm, val) ((rtm)->Timing.offsetTimesArray = (val))
#endif

#ifndef rtmGetOffsetTimePtr
# define rtmGetOffsetTimePtr(rtm)      ((rtm)->Timing.offsetTimes)
#endif

#ifndef rtmSetOffsetTimePtr
# define rtmSetOffsetTimePtr(rtm, val) ((rtm)->Timing.offsetTimes = (val))
#endif

#ifndef rtmGetOptions
# define rtmGetOptions(rtm)            ((rtm)->Sizes.options)
#endif

#ifndef rtmSetOptions
# define rtmSetOptions(rtm, val)       ((rtm)->Sizes.options = (val))
#endif

#ifndef rtmGetParamIsMalloced
# define rtmGetParamIsMalloced(rtm)    ()
#endif

#ifndef rtmSetParamIsMalloced
# define rtmSetParamIsMalloced(rtm, val) ()
#endif

#ifndef rtmGetPath
# define rtmGetPath(rtm)               ((rtm)->path)
#endif

#ifndef rtmSetPath
# define rtmSetPath(rtm, val)          ((rtm)->path = (val))
#endif

#ifndef rtmGetPerTaskSampleHits
# define rtmGetPerTaskSampleHits(rtm)  ()
#endif

#ifndef rtmSetPerTaskSampleHits
# define rtmSetPerTaskSampleHits(rtm, val) ()
#endif

#ifndef rtmGetPerTaskSampleHitsArray
# define rtmGetPerTaskSampleHitsArray(rtm) ((rtm)->Timing.perTaskSampleHitsArray)
#endif

#ifndef rtmSetPerTaskSampleHitsArray
# define rtmSetPerTaskSampleHitsArray(rtm, val) ((rtm)->Timing.perTaskSampleHitsArray = (val))
#endif

#ifndef rtmGetPerTaskSampleHitsPtr
# define rtmGetPerTaskSampleHitsPtr(rtm) ((rtm)->Timing.perTaskSampleHits)
#endif

#ifndef rtmSetPerTaskSampleHitsPtr
# define rtmSetPerTaskSampleHitsPtr(rtm, val) ((rtm)->Timing.perTaskSampleHits = (val))
#endif

#ifndef rtmGetPrevZCSigState
# define rtmGetPrevZCSigState(rtm)     ((rtm)->ModelData.prevZCSigState)
#endif

#ifndef rtmSetPrevZCSigState
# define rtmSetPrevZCSigState(rtm, val) ((rtm)->ModelData.prevZCSigState = (val))
#endif

#ifndef rtmGetRTWExtModeInfo
# define rtmGetRTWExtModeInfo(rtm)     ((rtm)->extModeInfo)
#endif

#ifndef rtmSetRTWExtModeInfo
# define rtmSetRTWExtModeInfo(rtm, val) ((rtm)->extModeInfo = (val))
#endif

#ifndef rtmGetRTWGeneratedSFcn
# define rtmGetRTWGeneratedSFcn(rtm)   ((rtm)->Sizes.rtwGenSfcn)
#endif

#ifndef rtmSetRTWGeneratedSFcn
# define rtmSetRTWGeneratedSFcn(rtm, val) ((rtm)->Sizes.rtwGenSfcn = (val))
#endif

#ifndef rtmGetRTWLogInfo
# define rtmGetRTWLogInfo(rtm)         ((rtm)->rtwLogInfo)
#endif

#ifndef rtmSetRTWLogInfo
# define rtmSetRTWLogInfo(rtm, val)    ((rtm)->rtwLogInfo = (val))
#endif

#ifndef rtmGetRTWRTModelMethodsInfo
# define rtmGetRTWRTModelMethodsInfo(rtm) ()
#endif

#ifndef rtmSetRTWRTModelMethodsInfo
# define rtmSetRTWRTModelMethodsInfo(rtm, val) ()
#endif

#ifndef rtmGetRTWSfcnInfo
# define rtmGetRTWSfcnInfo(rtm)        ((rtm)->sfcnInfo)
#endif

#ifndef rtmSetRTWSfcnInfo
# define rtmSetRTWSfcnInfo(rtm, val)   ((rtm)->sfcnInfo = (val))
#endif

#ifndef rtmGetRTWSolverInfo
# define rtmGetRTWSolverInfo(rtm)      ((rtm)->solverInfo)
#endif

#ifndef rtmSetRTWSolverInfo
# define rtmSetRTWSolverInfo(rtm, val) ((rtm)->solverInfo = (val))
#endif

#ifndef rtmGetRTWSolverInfoPtr
# define rtmGetRTWSolverInfoPtr(rtm)   ((rtm)->solverInfoPtr)
#endif

#ifndef rtmSetRTWSolverInfoPtr
# define rtmSetRTWSolverInfoPtr(rtm, val) ((rtm)->solverInfoPtr = (val))
#endif

#ifndef rtmGetReservedForXPC
# define rtmGetReservedForXPC(rtm)     ((rtm)->SpecialInfo.xpcData)
#endif

#ifndef rtmSetReservedForXPC
# define rtmSetReservedForXPC(rtm, val) ((rtm)->SpecialInfo.xpcData = (val))
#endif

#ifndef rtmGetRootDWork
# define rtmGetRootDWork(rtm)          ((rtm)->ModelData.dwork)
#endif

#ifndef rtmSetRootDWork
# define rtmSetRootDWork(rtm, val)     ((rtm)->ModelData.dwork = (val))
#endif

#ifndef rtmGetSFunctions
# define rtmGetSFunctions(rtm)         ((rtm)->childSfunctions)
#endif

#ifndef rtmSetSFunctions
# define rtmSetSFunctions(rtm, val)    ((rtm)->childSfunctions = (val))
#endif

#ifndef rtmGetSampleHitArray
# define rtmGetSampleHitArray(rtm)     ((rtm)->Timing.sampleHitArray)
#endif

#ifndef rtmSetSampleHitArray
# define rtmSetSampleHitArray(rtm, val) ((rtm)->Timing.sampleHitArray = (val))
#endif

#ifndef rtmGetSampleHitPtr
# define rtmGetSampleHitPtr(rtm)       ((rtm)->Timing.sampleHits)
#endif

#ifndef rtmSetSampleHitPtr
# define rtmSetSampleHitPtr(rtm, val)  ((rtm)->Timing.sampleHits = (val))
#endif

#ifndef rtmGetSampleTimeArray
# define rtmGetSampleTimeArray(rtm)    ((rtm)->Timing.sampleTimesArray)
#endif

#ifndef rtmSetSampleTimeArray
# define rtmSetSampleTimeArray(rtm, val) ((rtm)->Timing.sampleTimesArray = (val))
#endif

#ifndef rtmGetSampleTimePtr
# define rtmGetSampleTimePtr(rtm)      ((rtm)->Timing.sampleTimes)
#endif

#ifndef rtmSetSampleTimePtr
# define rtmSetSampleTimePtr(rtm, val) ((rtm)->Timing.sampleTimes = (val))
#endif

#ifndef rtmGetSampleTimeTaskIDArray
# define rtmGetSampleTimeTaskIDArray(rtm) ((rtm)->Timing.sampleTimeTaskIDArray)
#endif

#ifndef rtmSetSampleTimeTaskIDArray
# define rtmSetSampleTimeTaskIDArray(rtm, val) ((rtm)->Timing.sampleTimeTaskIDArray = (val))
#endif

#ifndef rtmGetSampleTimeTaskIDPtr
# define rtmGetSampleTimeTaskIDPtr(rtm) ((rtm)->Timing.sampleTimeTaskIDPtr)
#endif

#ifndef rtmSetSampleTimeTaskIDPtr
# define rtmSetSampleTimeTaskIDPtr(rtm, val) ((rtm)->Timing.sampleTimeTaskIDPtr = (val))
#endif

#ifndef rtmGetSimMode
# define rtmGetSimMode(rtm)            ((rtm)->simMode)
#endif

#ifndef rtmSetSimMode
# define rtmSetSimMode(rtm, val)       ((rtm)->simMode = (val))
#endif

#ifndef rtmGetSimTimeStep
# define rtmGetSimTimeStep(rtm)        ((rtm)->Timing.simTimeStep)
#endif

#ifndef rtmSetSimTimeStep
# define rtmSetSimTimeStep(rtm, val)   ((rtm)->Timing.simTimeStep = (val))
#endif

#ifndef rtmGetStartTime
# define rtmGetStartTime(rtm)          ((rtm)->Timing.tStart)
#endif

#ifndef rtmSetStartTime
# define rtmSetStartTime(rtm, val)     ((rtm)->Timing.tStart = (val))
#endif

#ifndef rtmGetStepSize
# define rtmGetStepSize(rtm)           ((rtm)->Timing.stepSize)
#endif

#ifndef rtmSetStepSize
# define rtmSetStepSize(rtm, val)      ((rtm)->Timing.stepSize = (val))
#endif

#ifndef rtmGetStopRequestedFlag
# define rtmGetStopRequestedFlag(rtm)  ((rtm)->Timing.stopRequestedFlag)
#endif

#ifndef rtmSetStopRequestedFlag
# define rtmSetStopRequestedFlag(rtm, val) ((rtm)->Timing.stopRequestedFlag = (val))
#endif

#ifndef rtmGetTaskCounters
# define rtmGetTaskCounters(rtm)       ()
#endif

#ifndef rtmSetTaskCounters
# define rtmSetTaskCounters(rtm, val)  ()
#endif

#ifndef rtmGetTaskTimeArray
# define rtmGetTaskTimeArray(rtm)      ((rtm)->Timing.tArray)
#endif

#ifndef rtmSetTaskTimeArray
# define rtmSetTaskTimeArray(rtm, val) ((rtm)->Timing.tArray = (val))
#endif

#ifndef rtmGetTimePtr
# define rtmGetTimePtr(rtm)            ((rtm)->Timing.t)
#endif

#ifndef rtmSetTimePtr
# define rtmSetTimePtr(rtm, val)       ((rtm)->Timing.t = (val))
#endif

#ifndef rtmGetTimingData
# define rtmGetTimingData(rtm)         ((rtm)->Timing.timingData)
#endif

#ifndef rtmSetTimingData
# define rtmSetTimingData(rtm, val)    ((rtm)->Timing.timingData = (val))
#endif

#ifndef rtmGetU
# define rtmGetU(rtm)                  ((rtm)->ModelData.inputs)
#endif

#ifndef rtmSetU
# define rtmSetU(rtm, val)             ((rtm)->ModelData.inputs = (val))
#endif

#ifndef rtmGetVarNextHitTimesListPtr
# define rtmGetVarNextHitTimesListPtr(rtm) ((rtm)->Timing.varNextHitTimesList)
#endif

#ifndef rtmSetVarNextHitTimesListPtr
# define rtmSetVarNextHitTimesListPtr(rtm, val) ((rtm)->Timing.varNextHitTimesList = (val))
#endif

#ifndef rtmGetY
# define rtmGetY(rtm)                  ((rtm)->ModelData.outputs)
#endif

#ifndef rtmSetY
# define rtmSetY(rtm, val)             ((rtm)->ModelData.outputs = (val))
#endif

#ifndef rtmGetZCCacheNeedsReset
# define rtmGetZCCacheNeedsReset(rtm)  ((rtm)->ModelData.zCCacheNeedsReset)
#endif

#ifndef rtmSetZCCacheNeedsReset
# define rtmSetZCCacheNeedsReset(rtm, val) ((rtm)->ModelData.zCCacheNeedsReset = (val))
#endif

#ifndef rtmGetZCSignalValues
# define rtmGetZCSignalValues(rtm)     ((rtm)->ModelData.zcSignalValues)
#endif

#ifndef rtmSetZCSignalValues
# define rtmSetZCSignalValues(rtm, val) ((rtm)->ModelData.zcSignalValues = (val))
#endif

#ifndef rtmGet_TimeOfLastOutput
# define rtmGet_TimeOfLastOutput(rtm)  ((rtm)->Timing.timeOfLastOutput)
#endif

#ifndef rtmSet_TimeOfLastOutput
# define rtmSet_TimeOfLastOutput(rtm, val) ((rtm)->Timing.timeOfLastOutput = (val))
#endif

#ifndef rtmGetdX
# define rtmGetdX(rtm)                 ((rtm)->ModelData.derivs)
#endif

#ifndef rtmSetdX
# define rtmSetdX(rtm, val)            ((rtm)->ModelData.derivs = (val))
#endif

#ifndef rtmGetChecksumVal
# define rtmGetChecksumVal(rtm, idx)   ((rtm)->Sizes.checksums[idx])
#endif

#ifndef rtmSetChecksumVal
# define rtmSetChecksumVal(rtm, idx, val) ((rtm)->Sizes.checksums[idx] = (val))
#endif

#ifndef rtmGetDWork
# define rtmGetDWork(rtm, idx)         ((rtm)->ModelData.dwork[idx])
#endif

#ifndef rtmSetDWork
# define rtmSetDWork(rtm, idx, val)    ((rtm)->ModelData.dwork[idx] = (val))
#endif

#ifndef rtmGetOffsetTime
# define rtmGetOffsetTime(rtm, idx)    ((rtm)->Timing.offsetTimes[idx])
#endif

#ifndef rtmSetOffsetTime
# define rtmSetOffsetTime(rtm, idx, val) ((rtm)->Timing.offsetTimes[idx] = (val))
#endif

#ifndef rtmGetSFunction
# define rtmGetSFunction(rtm, idx)     ((rtm)->childSfunctions[idx])
#endif

#ifndef rtmSetSFunction
# define rtmSetSFunction(rtm, idx, val) ((rtm)->childSfunctions[idx] = (val))
#endif

#ifndef rtmGetSampleTime
# define rtmGetSampleTime(rtm, idx)    ((rtm)->Timing.sampleTimes[idx])
#endif

#ifndef rtmSetSampleTime
# define rtmSetSampleTime(rtm, idx, val) ((rtm)->Timing.sampleTimes[idx] = (val))
#endif

#ifndef rtmGetSampleTimeTaskID
# define rtmGetSampleTimeTaskID(rtm, idx) ((rtm)->Timing.sampleTimeTaskIDPtr[idx])
#endif

#ifndef rtmSetSampleTimeTaskID
# define rtmSetSampleTimeTaskID(rtm, idx, val) ((rtm)->Timing.sampleTimeTaskIDPtr[idx] = (val))
#endif

#ifndef rtmGetVarNextHitTimeList
# define rtmGetVarNextHitTimeList(rtm, idx) ((rtm)->Timing.varNextHitTimesList[idx])
#endif

#ifndef rtmSetVarNextHitTimeList
# define rtmSetVarNextHitTimeList(rtm, idx, val) ((rtm)->Timing.varNextHitTimesList[idx] = (val))
#endif

#ifndef rtmIsContinuousTask
# define rtmIsContinuousTask(rtm, tid) ((tid) == 0)
#endif

#ifndef rtmGetErrorStatus
# define rtmGetErrorStatus(rtm)        ((rtm)->errorStatus)
#endif

#ifndef rtmSetErrorStatus
# define rtmSetErrorStatus(rtm, val)   ((rtm)->errorStatus = (val))
#endif

#ifndef rtmSetFirstInitCond
# define rtmSetFirstInitCond(rtm, val) ((rtm)->Timing.firstInitCondFlag = (val))
#endif

#ifndef rtmIsFirstInitCond
# define rtmIsFirstInitCond(rtm)       ((rtm)->Timing.firstInitCondFlag)
#endif

#ifndef rtmIsMajorTimeStep
# define rtmIsMajorTimeStep(rtm)       (((rtm)->Timing.simTimeStep) == MAJOR_TIME_STEP)
#endif

#ifndef rtmIsMinorTimeStep
# define rtmIsMinorTimeStep(rtm)       (((rtm)->Timing.simTimeStep) == MINOR_TIME_STEP)
#endif

#ifndef rtmIsSampleHit
# define rtmIsSampleHit(rtm, sti, tid) ((rtmIsMajorTimeStep((rtm)) && (rtm)->Timing.sampleHits[(rtm)->Timing.sampleTimeTaskIDPtr[sti]]))
#endif

#ifndef rtmGetStopRequested
# define rtmGetStopRequested(rtm)      ((rtm)->Timing.stopRequestedFlag)
#endif

#ifndef rtmSetStopRequested
# define rtmSetStopRequested(rtm, val) ((rtm)->Timing.stopRequestedFlag = (val))
#endif

#ifndef rtmGetStopRequestedPtr
# define rtmGetStopRequestedPtr(rtm)   (&((rtm)->Timing.stopRequestedFlag))
#endif

#ifndef rtmGetT
# define rtmGetT(rtm)                  (rtmGetTPtr((rtm))[0])
#endif

#ifndef rtmSetT
# define rtmSetT(rtm, val)                                       /* Do Nothing */
#endif

#ifndef rtmGetTFinal
# define rtmGetTFinal(rtm)             ((rtm)->Timing.tFinal)
#endif

#ifndef rtmSetTFinal
# define rtmSetTFinal(rtm, val)        ((rtm)->Timing.tFinal = (val))
#endif

#ifndef rtmGetTPtr
# define rtmGetTPtr(rtm)               ((rtm)->Timing.t)
#endif

#ifndef rtmSetTPtr
# define rtmSetTPtr(rtm, val)          ((rtm)->Timing.t = (val))
#endif

#ifndef rtmGetTStart
# define rtmGetTStart(rtm)             ((rtm)->Timing.tStart)
#endif

#ifndef rtmSetTStart
# define rtmSetTStart(rtm, val)        ((rtm)->Timing.tStart = (val))
#endif

#ifndef rtmGetTaskTime
# define rtmGetTaskTime(rtm, sti)      (rtmGetTPtr((rtm))[(rtm)->Timing.sampleTimeTaskIDPtr[sti]])
#endif

#ifndef rtmSetTaskTime
# define rtmSetTaskTime(rtm, sti, val) (rtmGetTPtr((rtm))[sti] = (val))
#endif

#ifndef rtmGetTimeOfLastOutput
# define rtmGetTimeOfLastOutput(rtm)   ((rtm)->Timing.timeOfLastOutput)
#endif

#ifdef rtmGetRTWSolverInfo
#undef rtmGetRTWSolverInfo
#endif

#define rtmGetRTWSolverInfo(rtm)       &((rtm)->solverInfo)

/* Definition for use in the target main file */
#define CSE1_HIL_u_rtModel             RT_MODEL_CSE1_HIL_u_T

/* Block signals (auto storage) */
typedef struct {
  real_T integrator_reset;             /* '<Root>/integrator_reset' */
  real_T Memory3;                      /* '<S4>/Memory3' */
  real_T Memory4;                      /* '<S4>/Memory4' */
  real_T Memory5;                      /* '<S4>/Memory5' */
  real_T Position[3];                  /* '<Root>/Position' */
  real_T Velocity[3];                  /* '<Root>/Velocity' */
  real_T u_BT;                         /* '<S10>/u_BT' */
  real_T u_VSP1;                       /* '<S10>/u_VSP1' */
  real_T u_VSP2;                       /* '<S10>/u_VSP2' */
  real_T alpha_VSP1;                   /* '<S10>/alpha_VSP1' */
  real_T alpha_VSP2;                   /* '<S10>/alpha_VSP2' */
  real_T omega_VSP1;                   /* '<S10>/omega_VSP1' */
  real_T omega_VSP2;                   /* '<S10>/omega_VSP2' */
  real_T psi_0;                        /* '<S4>/psi_0' */
  real_T x_0;                          /* '<S4>/x_0' */
  real_T y_0;                          /* '<S4>/y_0' */
  real_T nu_dot[3];                    /* '<Root>/kinetics' */
  real_T eta_dot[3];                   /* '<Root>/kinematics' */
  real_T X;                            /* '<Root>/Thruster configuration matrix' */
  real_T Y;                            /* '<Root>/Thruster configuration matrix' */
  real_T N;                            /* '<Root>/Thruster configuration matrix' */
} B_CSE1_HIL_u_T;

/* Block states (auto storage) for system '<Root>' */
typedef struct {
  real_T integrator_reset_DWORK1;      /* '<Root>/integrator_reset' */
  real_T Memory3_PreviousInput;        /* '<S4>/Memory3' */
  real_T Memory4_PreviousInput;        /* '<S4>/Memory4' */
  real_T Memory5_PreviousInput;        /* '<S4>/Memory5' */
  real_T x_DWORK1;                     /* '<S3>/x' */
  real_T y_DWORK1;                     /* '<S3>/y' */
  real_T psi_DWORK1;                   /* '<S3>/psi' */
  real_T r_DWORK1;                     /* '<S7>/r' */
  real_T u_DWORK1;                     /* '<S7>/u' */
  real_T v_DWORK1;                     /* '<S7>/v' */
  real_T u_BT_DWORK1;                  /* '<S10>/u_BT' */
  real_T u_VSP1_DWORK1;                /* '<S10>/u_VSP1' */
  real_T u_VSP2_DWORK1;                /* '<S10>/u_VSP2' */
  real_T alpha_VSP1_DWORK1;            /* '<S10>/alpha_VSP1' */
  real_T alpha_VSP2_DWORK1;            /* '<S10>/alpha_VSP2' */
  real_T omega_VSP1_DWORK1;            /* '<S10>/omega_VSP1' */
  real_T omega_VSP2_DWORK1;            /* '<S10>/omega_VSP2' */
  real_T r_dot_DWORK1;                 /* '<S8>/r_dot' */
  real_T u_dot_DWORK1;                 /* '<S8>/u_dot' */
  real_T v_dot_DWORK1;                 /* '<S8>/v_dot' */
  real_T X_DWORK1;                     /* '<S9>/X' */
  real_T Y_DWORK1;                     /* '<S9>/Y' */
  real_T N_DWORK1;                     /* '<S9>/N' */
  real_T psi_0_DWORK1;                 /* '<S4>/psi_0' */
  real_T x_0_DWORK1;                   /* '<S4>/x_0' */
  real_T y_0_DWORK1;                   /* '<S4>/y_0' */
  struct {
    int_T IcNeedsLoading;
  } Position_IWORK;                    /* '<Root>/Position' */

  uint8_T integrator_reset_DWORK2[11]; /* '<Root>/integrator_reset' */
  uint8_T x_DWORK2[11];                /* '<S3>/x' */
  uint8_T y_DWORK2[11];                /* '<S3>/y' */
  uint8_T psi_DWORK2[11];              /* '<S3>/psi' */
  uint8_T r_DWORK2[11];                /* '<S7>/r' */
  uint8_T u_DWORK2[11];                /* '<S7>/u' */
  uint8_T v_DWORK2[11];                /* '<S7>/v' */
  uint8_T u_BT_DWORK2[11];             /* '<S10>/u_BT' */
  uint8_T u_VSP1_DWORK2[11];           /* '<S10>/u_VSP1' */
  uint8_T u_VSP2_DWORK2[11];           /* '<S10>/u_VSP2' */
  uint8_T alpha_VSP1_DWORK2[11];       /* '<S10>/alpha_VSP1' */
  uint8_T alpha_VSP2_DWORK2[11];       /* '<S10>/alpha_VSP2' */
  uint8_T omega_VSP1_DWORK2[11];       /* '<S10>/omega_VSP1' */
  uint8_T omega_VSP2_DWORK2[11];       /* '<S10>/omega_VSP2' */
  uint8_T r_dot_DWORK2[11];            /* '<S8>/r_dot' */
  uint8_T u_dot_DWORK2[11];            /* '<S8>/u_dot' */
  uint8_T v_dot_DWORK2[11];            /* '<S8>/v_dot' */
  uint8_T X_DWORK2[11];                /* '<S9>/X' */
  uint8_T Y_DWORK2[11];                /* '<S9>/Y' */
  uint8_T N_DWORK2[11];                /* '<S9>/N' */
  uint8_T psi_0_DWORK2[11];            /* '<S4>/psi_0' */
  uint8_T x_0_DWORK2[11];              /* '<S4>/x_0' */
  uint8_T y_0_DWORK2[11];              /* '<S4>/y_0' */
} DW_CSE1_HIL_u_T;

/* Continuous states (auto storage) */
typedef struct {
  real_T Position_CSTATE[3];           /* '<Root>/Position' */
  real_T Velocity_CSTATE[3];           /* '<Root>/Velocity' */
} X_CSE1_HIL_u_T;

/* State derivatives (auto storage) */
typedef struct {
  real_T Position_CSTATE[3];           /* '<Root>/Position' */
  real_T Velocity_CSTATE[3];           /* '<Root>/Velocity' */
} XDot_CSE1_HIL_u_T;

/* State disabled  */
typedef struct {
  boolean_T Position_CSTATE[3];        /* '<Root>/Position' */
  boolean_T Velocity_CSTATE[3];        /* '<Root>/Velocity' */
} XDis_CSE1_HIL_u_T;

/* Zero-crossing (trigger) state */
typedef struct {
  ZCSigState Position_Reset_ZCE;       /* '<Root>/Position' */
  ZCSigState Velocity_Reset_ZCE;       /* '<Root>/Velocity' */
} PrevZCX_CSE1_HIL_u_T;

#ifndef ODE4_INTG
#define ODE4_INTG

/* ODE4 Integration Data */
typedef struct {
  real_T *y;                           /* output */
  real_T *f[4];                        /* derivatives */
} ODE4_IntgData;

#endif

/* Backward compatible GRT Identifiers */
#define rtB                            CSE1_HIL_u_B
#define BlockIO                        B_CSE1_HIL_u_T
#define rtX                            CSE1_HIL_u_X
#define ContinuousStates               X_CSE1_HIL_u_T
#define rtXdot                         CSE1_HIL_u_XDot
#define StateDerivatives               XDot_CSE1_HIL_u_T
#define tXdis                          CSE1_HIL_u_XDis
#define StateDisabled                  XDis_CSE1_HIL_u_T
#define rtP                            CSE1_HIL_u_P
#define Parameters                     P_CSE1_HIL_u_T
#define rtDWork                        CSE1_HIL_u_DW
#define D_Work                         DW_CSE1_HIL_u_T
#define rtPrevZCSigState               CSE1_HIL_u_PrevZCX
#define PrevZCSigStates                PrevZCX_CSE1_HIL_u_T

/* Parameters (auto storage) */
struct P_CSE1_HIL_u_T_ {
  real_T integrator_reset_P1;          /* Expression: width
                                        * Referenced by: '<Root>/integrator_reset'
                                        */
  real_T integrator_reset_P2;          /* Expression: dtype
                                        * Referenced by: '<Root>/integrator_reset'
                                        */
  real_T integrator_reset_P3;          /* Expression: portnum
                                        * Referenced by: '<Root>/integrator_reset'
                                        */
  real_T integrator_reset_P4;          /* Expression: stime
                                        * Referenced by: '<Root>/integrator_reset'
                                        */
  real_T integrator_reset_P5;          /* Expression: stype
                                        * Referenced by: '<Root>/integrator_reset'
                                        */
  real_T integrator_reset_P6;          /* Expression: btype
                                        * Referenced by: '<Root>/integrator_reset'
                                        */
  real_T Memory3_X0;                   /* Expression: 0
                                        * Referenced by: '<S4>/Memory3'
                                        */
  real_T Memory4_X0;                   /* Expression: 0
                                        * Referenced by: '<S4>/Memory4'
                                        */
  real_T Memory5_X0;                   /* Expression: 0
                                        * Referenced by: '<S4>/Memory5'
                                        */
  real_T x_P1;                         /* Expression: width
                                        * Referenced by: '<S3>/x'
                                        */
  real_T x_P2;                         /* Expression: dtype
                                        * Referenced by: '<S3>/x'
                                        */
  real_T x_P3;                         /* Expression: portnum
                                        * Referenced by: '<S3>/x'
                                        */
  real_T x_P4;                         /* Expression: stime
                                        * Referenced by: '<S3>/x'
                                        */
  real_T x_P5;                         /* Expression: stype
                                        * Referenced by: '<S3>/x'
                                        */
  real_T x_P6;                         /* Expression: btype
                                        * Referenced by: '<S3>/x'
                                        */
  real_T y_P1;                         /* Expression: width
                                        * Referenced by: '<S3>/y'
                                        */
  real_T y_P2;                         /* Expression: dtype
                                        * Referenced by: '<S3>/y'
                                        */
  real_T y_P3;                         /* Expression: portnum
                                        * Referenced by: '<S3>/y'
                                        */
  real_T y_P4;                         /* Expression: stime
                                        * Referenced by: '<S3>/y'
                                        */
  real_T y_P5;                         /* Expression: stype
                                        * Referenced by: '<S3>/y'
                                        */
  real_T y_P6;                         /* Expression: btype
                                        * Referenced by: '<S3>/y'
                                        */
  real_T psi_P1;                       /* Expression: width
                                        * Referenced by: '<S3>/psi'
                                        */
  real_T psi_P2;                       /* Expression: dtype
                                        * Referenced by: '<S3>/psi'
                                        */
  real_T psi_P3;                       /* Expression: portnum
                                        * Referenced by: '<S3>/psi'
                                        */
  real_T psi_P4;                       /* Expression: stime
                                        * Referenced by: '<S3>/psi'
                                        */
  real_T psi_P5;                       /* Expression: stype
                                        * Referenced by: '<S3>/psi'
                                        */
  real_T psi_P6;                       /* Expression: btype
                                        * Referenced by: '<S3>/psi'
                                        */
  real_T Velocity_IC[3];               /* Expression: [0 0 0]'
                                        * Referenced by: '<Root>/Velocity'
                                        */
  real_T r_P1;                         /* Expression: width
                                        * Referenced by: '<S7>/r'
                                        */
  real_T r_P2;                         /* Expression: dtype
                                        * Referenced by: '<S7>/r'
                                        */
  real_T r_P3;                         /* Expression: portnum
                                        * Referenced by: '<S7>/r'
                                        */
  real_T r_P4;                         /* Expression: stime
                                        * Referenced by: '<S7>/r'
                                        */
  real_T r_P5;                         /* Expression: stype
                                        * Referenced by: '<S7>/r'
                                        */
  real_T r_P6;                         /* Expression: btype
                                        * Referenced by: '<S7>/r'
                                        */
  real_T u_P1;                         /* Expression: width
                                        * Referenced by: '<S7>/u'
                                        */
  real_T u_P2;                         /* Expression: dtype
                                        * Referenced by: '<S7>/u'
                                        */
  real_T u_P3;                         /* Expression: portnum
                                        * Referenced by: '<S7>/u'
                                        */
  real_T u_P4;                         /* Expression: stime
                                        * Referenced by: '<S7>/u'
                                        */
  real_T u_P5;                         /* Expression: stype
                                        * Referenced by: '<S7>/u'
                                        */
  real_T u_P6;                         /* Expression: btype
                                        * Referenced by: '<S7>/u'
                                        */
  real_T v_P1;                         /* Expression: width
                                        * Referenced by: '<S7>/v'
                                        */
  real_T v_P2;                         /* Expression: dtype
                                        * Referenced by: '<S7>/v'
                                        */
  real_T v_P3;                         /* Expression: portnum
                                        * Referenced by: '<S7>/v'
                                        */
  real_T v_P4;                         /* Expression: stime
                                        * Referenced by: '<S7>/v'
                                        */
  real_T v_P5;                         /* Expression: stype
                                        * Referenced by: '<S7>/v'
                                        */
  real_T v_P6;                         /* Expression: btype
                                        * Referenced by: '<S7>/v'
                                        */
  real_T u_BT_P1;                      /* Expression: width
                                        * Referenced by: '<S10>/u_BT'
                                        */
  real_T u_BT_P2;                      /* Expression: dtype
                                        * Referenced by: '<S10>/u_BT'
                                        */
  real_T u_BT_P3;                      /* Expression: portnum
                                        * Referenced by: '<S10>/u_BT'
                                        */
  real_T u_BT_P4;                      /* Expression: stime
                                        * Referenced by: '<S10>/u_BT'
                                        */
  real_T u_BT_P5;                      /* Expression: stype
                                        * Referenced by: '<S10>/u_BT'
                                        */
  real_T u_BT_P6;                      /* Expression: btype
                                        * Referenced by: '<S10>/u_BT'
                                        */
  real_T u_VSP1_P1;                    /* Expression: width
                                        * Referenced by: '<S10>/u_VSP1'
                                        */
  real_T u_VSP1_P2;                    /* Expression: dtype
                                        * Referenced by: '<S10>/u_VSP1'
                                        */
  real_T u_VSP1_P3;                    /* Expression: portnum
                                        * Referenced by: '<S10>/u_VSP1'
                                        */
  real_T u_VSP1_P4;                    /* Expression: stime
                                        * Referenced by: '<S10>/u_VSP1'
                                        */
  real_T u_VSP1_P5;                    /* Expression: stype
                                        * Referenced by: '<S10>/u_VSP1'
                                        */
  real_T u_VSP1_P6;                    /* Expression: btype
                                        * Referenced by: '<S10>/u_VSP1'
                                        */
  real_T u_VSP2_P1;                    /* Expression: width
                                        * Referenced by: '<S10>/u_VSP2'
                                        */
  real_T u_VSP2_P2;                    /* Expression: dtype
                                        * Referenced by: '<S10>/u_VSP2'
                                        */
  real_T u_VSP2_P3;                    /* Expression: portnum
                                        * Referenced by: '<S10>/u_VSP2'
                                        */
  real_T u_VSP2_P4;                    /* Expression: stime
                                        * Referenced by: '<S10>/u_VSP2'
                                        */
  real_T u_VSP2_P5;                    /* Expression: stype
                                        * Referenced by: '<S10>/u_VSP2'
                                        */
  real_T u_VSP2_P6;                    /* Expression: btype
                                        * Referenced by: '<S10>/u_VSP2'
                                        */
  real_T alpha_VSP1_P1;                /* Expression: width
                                        * Referenced by: '<S10>/alpha_VSP1'
                                        */
  real_T alpha_VSP1_P2;                /* Expression: dtype
                                        * Referenced by: '<S10>/alpha_VSP1'
                                        */
  real_T alpha_VSP1_P3;                /* Expression: portnum
                                        * Referenced by: '<S10>/alpha_VSP1'
                                        */
  real_T alpha_VSP1_P4;                /* Expression: stime
                                        * Referenced by: '<S10>/alpha_VSP1'
                                        */
  real_T alpha_VSP1_P5;                /* Expression: stype
                                        * Referenced by: '<S10>/alpha_VSP1'
                                        */
  real_T alpha_VSP1_P6;                /* Expression: btype
                                        * Referenced by: '<S10>/alpha_VSP1'
                                        */
  real_T alpha_VSP2_P1;                /* Expression: width
                                        * Referenced by: '<S10>/alpha_VSP2'
                                        */
  real_T alpha_VSP2_P2;                /* Expression: dtype
                                        * Referenced by: '<S10>/alpha_VSP2'
                                        */
  real_T alpha_VSP2_P3;                /* Expression: portnum
                                        * Referenced by: '<S10>/alpha_VSP2'
                                        */
  real_T alpha_VSP2_P4;                /* Expression: stime
                                        * Referenced by: '<S10>/alpha_VSP2'
                                        */
  real_T alpha_VSP2_P5;                /* Expression: stype
                                        * Referenced by: '<S10>/alpha_VSP2'
                                        */
  real_T alpha_VSP2_P6;                /* Expression: btype
                                        * Referenced by: '<S10>/alpha_VSP2'
                                        */
  real_T omega_VSP1_P1;                /* Expression: width
                                        * Referenced by: '<S10>/omega_VSP1'
                                        */
  real_T omega_VSP1_P2;                /* Expression: dtype
                                        * Referenced by: '<S10>/omega_VSP1'
                                        */
  real_T omega_VSP1_P3;                /* Expression: portnum
                                        * Referenced by: '<S10>/omega_VSP1'
                                        */
  real_T omega_VSP1_P4;                /* Expression: stime
                                        * Referenced by: '<S10>/omega_VSP1'
                                        */
  real_T omega_VSP1_P5;                /* Expression: stype
                                        * Referenced by: '<S10>/omega_VSP1'
                                        */
  real_T omega_VSP1_P6;                /* Expression: btype
                                        * Referenced by: '<S10>/omega_VSP1'
                                        */
  real_T omega_VSP2_P1;                /* Expression: width
                                        * Referenced by: '<S10>/omega_VSP2'
                                        */
  real_T omega_VSP2_P2;                /* Expression: dtype
                                        * Referenced by: '<S10>/omega_VSP2'
                                        */
  real_T omega_VSP2_P3;                /* Expression: portnum
                                        * Referenced by: '<S10>/omega_VSP2'
                                        */
  real_T omega_VSP2_P4;                /* Expression: stime
                                        * Referenced by: '<S10>/omega_VSP2'
                                        */
  real_T omega_VSP2_P5;                /* Expression: stype
                                        * Referenced by: '<S10>/omega_VSP2'
                                        */
  real_T omega_VSP2_P6;                /* Expression: btype
                                        * Referenced by: '<S10>/omega_VSP2'
                                        */
  real_T r_dot_P1;                     /* Expression: width
                                        * Referenced by: '<S8>/r_dot'
                                        */
  real_T r_dot_P2;                     /* Expression: dtype
                                        * Referenced by: '<S8>/r_dot'
                                        */
  real_T r_dot_P3;                     /* Expression: portnum
                                        * Referenced by: '<S8>/r_dot'
                                        */
  real_T r_dot_P4;                     /* Expression: stime
                                        * Referenced by: '<S8>/r_dot'
                                        */
  real_T r_dot_P5;                     /* Expression: stype
                                        * Referenced by: '<S8>/r_dot'
                                        */
  real_T r_dot_P6;                     /* Expression: btype
                                        * Referenced by: '<S8>/r_dot'
                                        */
  real_T u_dot_P1;                     /* Expression: width
                                        * Referenced by: '<S8>/u_dot'
                                        */
  real_T u_dot_P2;                     /* Expression: dtype
                                        * Referenced by: '<S8>/u_dot'
                                        */
  real_T u_dot_P3;                     /* Expression: portnum
                                        * Referenced by: '<S8>/u_dot'
                                        */
  real_T u_dot_P4;                     /* Expression: stime
                                        * Referenced by: '<S8>/u_dot'
                                        */
  real_T u_dot_P5;                     /* Expression: stype
                                        * Referenced by: '<S8>/u_dot'
                                        */
  real_T u_dot_P6;                     /* Expression: btype
                                        * Referenced by: '<S8>/u_dot'
                                        */
  real_T v_dot_P1;                     /* Expression: width
                                        * Referenced by: '<S8>/v_dot'
                                        */
  real_T v_dot_P2;                     /* Expression: dtype
                                        * Referenced by: '<S8>/v_dot'
                                        */
  real_T v_dot_P3;                     /* Expression: portnum
                                        * Referenced by: '<S8>/v_dot'
                                        */
  real_T v_dot_P4;                     /* Expression: stime
                                        * Referenced by: '<S8>/v_dot'
                                        */
  real_T v_dot_P5;                     /* Expression: stype
                                        * Referenced by: '<S8>/v_dot'
                                        */
  real_T v_dot_P6;                     /* Expression: btype
                                        * Referenced by: '<S8>/v_dot'
                                        */
  real_T X_P1;                         /* Expression: width
                                        * Referenced by: '<S9>/X'
                                        */
  real_T X_P2;                         /* Expression: dtype
                                        * Referenced by: '<S9>/X'
                                        */
  real_T X_P3;                         /* Expression: portnum
                                        * Referenced by: '<S9>/X'
                                        */
  real_T X_P4;                         /* Expression: stime
                                        * Referenced by: '<S9>/X'
                                        */
  real_T X_P5;                         /* Expression: stype
                                        * Referenced by: '<S9>/X'
                                        */
  real_T X_P6;                         /* Expression: btype
                                        * Referenced by: '<S9>/X'
                                        */
  real_T Y_P1;                         /* Expression: width
                                        * Referenced by: '<S9>/Y'
                                        */
  real_T Y_P2;                         /* Expression: dtype
                                        * Referenced by: '<S9>/Y'
                                        */
  real_T Y_P3;                         /* Expression: portnum
                                        * Referenced by: '<S9>/Y'
                                        */
  real_T Y_P4;                         /* Expression: stime
                                        * Referenced by: '<S9>/Y'
                                        */
  real_T Y_P5;                         /* Expression: stype
                                        * Referenced by: '<S9>/Y'
                                        */
  real_T Y_P6;                         /* Expression: btype
                                        * Referenced by: '<S9>/Y'
                                        */
  real_T N_P1;                         /* Expression: width
                                        * Referenced by: '<S9>/N'
                                        */
  real_T N_P2;                         /* Expression: dtype
                                        * Referenced by: '<S9>/N'
                                        */
  real_T N_P3;                         /* Expression: portnum
                                        * Referenced by: '<S9>/N'
                                        */
  real_T N_P4;                         /* Expression: stime
                                        * Referenced by: '<S9>/N'
                                        */
  real_T N_P5;                         /* Expression: stype
                                        * Referenced by: '<S9>/N'
                                        */
  real_T N_P6;                         /* Expression: btype
                                        * Referenced by: '<S9>/N'
                                        */
  real_T psi_0_P1;                     /* Expression: width
                                        * Referenced by: '<S4>/psi_0'
                                        */
  real_T psi_0_P2;                     /* Expression: dtype
                                        * Referenced by: '<S4>/psi_0'
                                        */
  real_T psi_0_P3;                     /* Expression: portnum
                                        * Referenced by: '<S4>/psi_0'
                                        */
  real_T psi_0_P4;                     /* Expression: stime
                                        * Referenced by: '<S4>/psi_0'
                                        */
  real_T psi_0_P5;                     /* Expression: stype
                                        * Referenced by: '<S4>/psi_0'
                                        */
  real_T psi_0_P6;                     /* Expression: btype
                                        * Referenced by: '<S4>/psi_0'
                                        */
  real_T x_0_P1;                       /* Expression: width
                                        * Referenced by: '<S4>/x_0'
                                        */
  real_T x_0_P2;                       /* Expression: dtype
                                        * Referenced by: '<S4>/x_0'
                                        */
  real_T x_0_P3;                       /* Expression: portnum
                                        * Referenced by: '<S4>/x_0'
                                        */
  real_T x_0_P4;                       /* Expression: stime
                                        * Referenced by: '<S4>/x_0'
                                        */
  real_T x_0_P5;                       /* Expression: stype
                                        * Referenced by: '<S4>/x_0'
                                        */
  real_T x_0_P6;                       /* Expression: btype
                                        * Referenced by: '<S4>/x_0'
                                        */
  real_T y_0_P1;                       /* Expression: width
                                        * Referenced by: '<S4>/y_0'
                                        */
  real_T y_0_P2;                       /* Expression: dtype
                                        * Referenced by: '<S4>/y_0'
                                        */
  real_T y_0_P3;                       /* Expression: portnum
                                        * Referenced by: '<S4>/y_0'
                                        */
  real_T y_0_P4;                       /* Expression: stime
                                        * Referenced by: '<S4>/y_0'
                                        */
  real_T y_0_P5;                       /* Expression: stype
                                        * Referenced by: '<S4>/y_0'
                                        */
  real_T y_0_P6;                       /* Expression: btype
                                        * Referenced by: '<S4>/y_0'
                                        */
};

/* Real-time Model Data Structure */
struct tag_RTM_CSE1_HIL_u_T {
  const char_T *path;
  const char_T *modelName;
  struct SimStruct_tag * *childSfunctions;
  const char_T *errorStatus;
  SS_SimMode simMode;
  RTWLogInfo *rtwLogInfo;
  RTWExtModeInfo *extModeInfo;
  RTWSolverInfo solverInfo;
  RTWSolverInfo *solverInfoPtr;
  void *sfcnInfo;

  /*
   * ModelData:
   * The following substructure contains information regarding
   * the data used in the model.
   */
  struct {
    void *blockIO;
    const void *constBlockIO;
    void *defaultParam;
    ZCSigState *prevZCSigState;
    real_T *contStates;
    real_T *derivs;
    void *zcSignalValues;
    void *inputs;
    void *outputs;
    boolean_T *contStateDisabled;
    boolean_T zCCacheNeedsReset;
    boolean_T derivCacheNeedsReset;
    boolean_T blkStateChange;
    real_T odeY[6];
    real_T odeF[4][6];
    ODE4_IntgData intgData;
    void *dwork;
  } ModelData;

  /*
   * Sizes:
   * The following substructure contains sizes information
   * for many of the model attributes such as inputs, outputs,
   * dwork, sample times, etc.
   */
  struct {
    uint32_T checksums[4];
    uint32_T options;
    int_T numContStates;
    int_T numU;
    int_T numY;
    int_T numSampTimes;
    int_T numBlocks;
    int_T numBlockIO;
    int_T numBlockPrms;
    int_T numDwork;
    int_T numSFcnPrms;
    int_T numSFcns;
    int_T numIports;
    int_T numOports;
    int_T numNonSampZCs;
    int_T sysDirFeedThru;
    int_T rtwGenSfcn;
  } Sizes;

  /*
   * SpecialInfo:
   * The following substructure contains special information
   * related to other components that are dependent on RTW.
   */
  struct {
    const void *mappingInfo;
    void *xpcData;
  } SpecialInfo;

  /*
   * Timing:
   * The following substructure contains information regarding
   * the timing information for the model.
   */
  struct {
    time_T stepSize;
    uint32_T clockTick0;
    uint32_T clockTickH0;
    time_T stepSize0;
    uint32_T clockTick1;
    uint32_T clockTickH1;
    time_T stepSize1;
    boolean_T firstInitCondFlag;
    time_T tStart;
    time_T tFinal;
    time_T timeOfLastOutput;
    void *timingData;
    real_T *varNextHitTimesList;
    SimTimeStep simTimeStep;
    boolean_T stopRequestedFlag;
    time_T *sampleTimes;
    time_T *offsetTimes;
    int_T *sampleTimeTaskIDPtr;
    int_T *sampleHits;
    int_T *perTaskSampleHits;
    time_T *t;
    time_T sampleTimesArray[2];
    time_T offsetTimesArray[2];
    int_T sampleTimeTaskIDArray[2];
    int_T sampleHitArray[2];
    int_T perTaskSampleHitsArray[4];
    time_T tArray[2];
  } Timing;
};

/* Block parameters (auto storage) */
extern P_CSE1_HIL_u_T CSE1_HIL_u_P;

/* Block signals (auto storage) */
extern B_CSE1_HIL_u_T CSE1_HIL_u_B;

/* Continuous states (auto storage) */
extern X_CSE1_HIL_u_T CSE1_HIL_u_X;

/* Block states (auto storage) */
extern DW_CSE1_HIL_u_T CSE1_HIL_u_DW;

/* Model entry point functions */
extern void CSE1_HIL_u_initialize(void);
extern void CSE1_HIL_u_output(void);
extern void CSE1_HIL_u_update(void);
extern void CSE1_HIL_u_terminate(void);

/* Real-time Model object */
extern RT_MODEL_CSE1_HIL_u_T *const CSE1_HIL_u_M;

/*-
 * The generated code includes comments that allow you to trace directly
 * back to the appropriate location in the model.  The basic format
 * is <system>/block_name, where system is the system number (uniquely
 * assigned by Simulink) and block_name is the name of the block.
 *
 * Use the MATLAB hilite_system command to trace the generated code back
 * to the model.  For example,
 *
 * hilite_system('<S3>')    - opens system 3
 * hilite_system('<S3>/Kp') - opens and selects block Kp which resides in S3
 *
 * Here is the system hierarchy for this model
 *
 * '<Root>' : 'CSE1_HIL_u'
 * '<S1>'   : 'CSE1_HIL_u/Thruster configuration matrix'
 * '<S2>'   : 'CSE1_HIL_u/Thruster mapping'
 * '<S3>'   : 'CSE1_HIL_u/eta'
 * '<S4>'   : 'CSE1_HIL_u/eta_0'
 * '<S5>'   : 'CSE1_HIL_u/kinematics'
 * '<S6>'   : 'CSE1_HIL_u/kinetics'
 * '<S7>'   : 'CSE1_HIL_u/nu'
 * '<S8>'   : 'CSE1_HIL_u/nu_dot'
 * '<S9>'   : 'CSE1_HIL_u/tau'
 * '<S10>'  : 'CSE1_HIL_u/u'
 * '<S11>'  : 'CSE1_HIL_u/Thruster mapping/Bow thruster'
 * '<S12>'  : 'CSE1_HIL_u/Thruster mapping/VSP'
 */
#endif                                 /* RTW_HEADER_CSE1_HIL_u_h_ */

/*========================================================================*
 * NI VeriStand Generated Code                                            *
 *========================================================================**/
#define NI_SIT_PARAMS
#ifdef NI_ROOTMODEL_CSE1_HIL_u
#ifndef NI_VERISTAND_MODELDATAFILE
#ifdef NI_VERISTAND_MAINMODELFILE

int READSIDE = 0;
int tid = 0;

#ifdef MULTITASKING

P_CSE1_HIL_u_T rtParameter[NUMST+!TID01EQ];
P_CSE1_HIL_u_T *param_lookup[NUMST][2] = {
  { &rtParameter[0], &rtParameter[1] },

  { &rtParameter[0], &rtParameter[1] },
};

#else

P_CSE1_HIL_u_T rtParameter[2];

#endif

#else

extern int READSIDE;

#ifdef MULTITASKING

extern int tid;
extern P_CSE1_HIL_u_T* param_lookup[NUMST][2];

#else

extern P_CSE1_HIL_u_T rtParameter[];

#endif
#endif

#ifdef MULTITASKING
#define CSE1_HIL_u_P                   (*param_lookup[tid][READSIDE])
#else
#define CSE1_HIL_u_P                   rtParameter[READSIDE]
#endif
#endif
#endif


text:
//
//  NSString+MeowString.h
//  EasyJieApp
//
//  Created by Meow on 16/4/7.
//  Copyright © 2016年 easyjie. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (CMString)

/**
 *  @author CleverMeow, 16-07-01 09:07:48
 *
 *  字符串分割
 *
 *  @param CharactersInSet 作为标志的字符串
 *
 *  @return 返回分割结果,以数组的形式
 */
- (NSArray *)cm_splitTheCharactersByCharactersInSet:(NSString *)charactersInSet;

- (NSString *)cm_replaceString:(NSString *)replaceStr withString:(NSString *)charactersInSet;

- (NSString *)cm_removeHtml;

@end


text:
package incognito.anonymization.redistribution

import org.apache.spark.mllib.linalg.Vector
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.rdd.RDD
import incognito.rdd.Data
import org.apache.spark.storage.StorageLevel
import incognito.rdd.ECS
import scala.collection.mutable.ArrayBuffer
import incognito.rdd.ECKey
import incognito.rdd.ECKey
import incognito.rdd.ECKey
import incognito.rdd.ECKey
import incognito.rdd.ECKey
import incognito.rdd.SATuple
import breeze.linalg.DenseVector
import org.apache.spark.rdd.RDD.rddToPairRDDFunctions
/**
 * @author Antorweep Chakravorty
 * @constructor a constructor to redistribute records into generated equivalence classes based
 * on the required sensitive attribute distribution and norms of the quasi identifers
 * @param data: the data set to be redistributed into equivalence classes
 * @param bucketsIn contains the buckets, their sizes and upperbound
 * @param ecSizesIn an Rdd of equivalence classes specifying the buckets and number of records that can be choosen from them
 * @param count the total number of records in the dataset
 */
class RedistributeBasedOnNorm(data: RDD[Data], bucketsIn: RDD[SATuple], ecSizesIn: RDD[ECS], count: Long) {
  /**
   * A method to redistibute records in buckets into equivalence classes.
   * The scalability is based on number of generated buckets
   * @return returns the eckey and data, the eckey represents the equivalence class to which the record belong to
   */
  def start(): RDD[(ECKey, Data)] = {

    //Measures the average of all numeric quasi identifiers
    val _avgNumericQI = data.map(v => (-1, v.qNumeric))
      .combineByKey((x: Vector) => x,
        (acc: Vector, x: Vector) => Vectors.dense((new DenseVector(acc.toArray) + new DenseVector(x.toArray)).toArray),
        (acc1: Vector, acc2: Vector) => Vectors.dense((new DenseVector(acc1.toArray) + new DenseVector(acc2.toArray)).toArray))
      .map(_._2)
      .reduce((acc1, acc2) => Vectors.dense((new DenseVector(acc1.toArray) + new DenseVector(acc2.toArray)).toArray))

    val avgNumericQI = new DenseVector(_avgNumericQI.toArray).map(_ / count)

    //Measures the standard deviation of all numeric quasi identifiers
    val _sdQI = data.map(v => (-1, Vectors.dense(
      (new DenseVector(v.qNumeric.toArray) - avgNumericQI).map(x => math.pow(x, 2)).toArray)))
      .combineByKey((x: Vector) => x,
        (acc: Vector, x: Vector) => Vectors.dense((new DenseVector(acc.toArray) + new DenseVector(x.toArray)).toArray),
        (acc1: Vector, acc2: Vector) => Vectors.dense((new DenseVector(acc1.toArray) + new DenseVector(acc2.toArray)).toArray))
      .map(_._2)
      .reduce((acc1, acc2) => Vectors.dense((new DenseVector(acc1.toArray) + new DenseVector(acc2.toArray)).toArray))

    val sdQI = new DenseVector(_sdQI.toArray).map(_ / count)

    //Standardizes all quasi identifer value
    val standarizedQIs = data.map({ v =>
      val zscore = Vectors.dense(((new DenseVector(v.qNumeric.toArray) - avgNumericQI) / sdQI).toArray)
      new Data(id = v.id, qNumeric = zscore, qCategorical = v.qCategorical, sa = v.sa)
    }).persist(StorageLevel.MEMORY_ONLY)

    implicit val KeyOrdering = new Ordering[(String, ECKey, Int)] {
      override def compare(x: (String, ECKey, Int), y: (String, ECKey, Int)): Int = {
        var rtn = x._1.compare(y._1)
        if (rtn == 0) {
          rtn = x._3.compare(y._3) * -1

          if (rtn == 0) {
            rtn = x._2.level.compare(y._2.level)

            if (rtn == 0) {
              rtn = x._2.sideParent.compareTo(y._2.sideParent)

              if (rtn == 0) {
                rtn = x._2.side.compare(y._2.side)
              }
            }
          }
        }
        rtn
      }
    }

    /*Maps the buckets and ecs together specifying which bucket how many records could be choosen
    * (Index, (bucket code, ecKey, size))
    */
    val bukECs = ecSizesIn
      .map(v => v.bucketCodeWithSize.map(b => ((b._1, v.ecKey), b._2)).toArray)
      .flatMap(f => f) //((bucket code, ecKey), size)
      .map({ v =>
        val out = new ArrayBuffer[(String, ECKey, Int)];
        //Select the
        for (i <- 0 until v._2) { out += ((v._1._1, v._1._2, v._2)) }; out.toArray
      })
      .flatMap(f => f) //(bucket code, ecKey, size), size
      .sortBy(_._1)
      .zipWithIndex
      .map({ case (k, v) => (v, k) }) //Index, (bucket code, ecKey, size)
      .persist(StorageLevel.MEMORY_ONLY)

    //Creates a record bucket map having the sa, bucketcode
    val tupleBucketMap = bucketsIn
      .map(b => b.sas.map(t => (t, b.bucketCode))).flatMap(f => f)

    /*Each record in the dataset are mapped with their SA in the bucket.
     *Duplicate records are expected for the overlapping buckets in case of incognito, since,
     * a sa could belong to multiple buckets.
     * bucket code, data
     */
    val _tupleBucketGroup = tupleBucketMap
      .join(standarizedQIs.map(d => (d.sa, d))).map(_._2)

    implicit val KeyOrderingBuckets = new Ordering[(Int, Double)] {
      override def compare(x: (Int, Double), y: (Int, Double)): Int = {
        var rtn = x._1.compare(y._1)
        if (rtn == 0) {
          rtn = x._2.compare(y._2)
        }

        rtn
      }
    }
    /*Creates as stored store of the datasets based their bucket and norm
     * Index (bukCode, norm, id)
    */
    val _dataWithNorm = _tupleBucketGroup
      .map(v => (v._1, Vectors.norm(v._2.qNumeric, 2.0), v._2.id))
      //Remove duplicate records which appears in multiple buckets, based on data id
      .map(v => (v._3, v)).reduceByKey({ (x, y) => (x) }).map(_._2)
      .sortBy(v => (v._1, v._2)) //sort by bukCode, norm
      .zipWithIndex
      .map({ case (k, v) => (v, k) })
      .persist(StorageLevel.MEMORY_ONLY)

    //Joins with the dataset to return record id and eckey
    val redistributedDataSet = _dataWithNorm
      .join(bukECs)
      .map(v => (v._2._1._3, v._2._2._2))

    redistributedDataSet
    .join(data.map(v => (v.id, v)))
    .map(_._2)

  }
}


text:
/**
 * @file
 **/

#include "modules/planning/tasks/optimizers/speed_optimizer.h"

#include "modules/planning/common/planning_gflags.h"
#include "modules/planning/common/speed_limit.h"

namespace apollo {
namespace planning {

using apollo::common::Status;
using apollo::planning_internal::STGraphDebug;

SpeedOptimizer::SpeedOptimizer(const TaskConfig& config) : Task(config) {}

Status SpeedOptimizer::Execute(Frame* frame,
                               ReferenceLineInfo* reference_line_info) {
  Task::Execute(frame, reference_line_info);

  auto ret =
      Process(reference_line_info->path_data(), frame->PlanningStartPoint(),
              reference_line_info->mutable_speed_data());

  RecordDebugInfo(reference_line_info->speed_data());
  return ret;
}

void SpeedOptimizer::RecordDebugInfo(const SpeedData& speed_data) {
  auto* debug = reference_line_info_->mutable_debug();
  auto ptr_speed_plan = debug->mutable_planning_data()->add_speed_plan();
  ptr_speed_plan->set_name(Name());
  ptr_speed_plan->mutable_speed_point()->CopyFrom(
      {speed_data.begin(), speed_data.end()});
}

void SpeedOptimizer::RecordDebugInfo(const SpeedData& speed_data,
                                     STGraphDebug* st_graph_debug) {
  if (!FLAGS_enable_record_debug || !st_graph_debug) {
    ADEBUG << "Skip record debug info";
    return;
  }
  st_graph_debug->set_name(Name());
  st_graph_debug->mutable_speed_profile()->CopyFrom(
      {speed_data.begin(), speed_data.end()});
}

}  // namespace planning
}  // namespace apollo


text:
module Cryptoexchange::Exchanges
  module Dextrade
    module Services
      class Trades < Cryptoexchange::Services::Market
        def fetch(market_pair)
          output = super(ticker_url(market_pair))
          adapt(output, market_pair)
        end

        def ticker_url(market_pair)
          base = market_pair.base.downcase
          target = market_pair.target.downcase
          "#{Cryptoexchange::Exchanges::Dextrade::Market::API_URL}/deals?symbol=#{base}#{target}"
        end

        def adapt(output, market_pair)
          output.collect do |trade|
            tr = Cryptoexchange::Models::Trade.new
            tr.base      = market_pair.base
            tr.target    = market_pair.target
            tr.market    = Dextrade::Market::NAME

            tr.type      = trade['direction']
            tr.price     = trade['price']
            tr.amount    = trade['amount']
            tr.timestamp = trade['trade_date'].to_i / 1000
            tr.payload   = trade

            tr
          end
        end
      end
    end
  end
end


text:
<?php

/*
	Section: Files

	- <multiply.php>
	- <multiply.common.php>
	- <multiply.server.php>
*/

/*
	@package xajax
	@version $Id: xajax.inc.php 362 2007-05-29 15:32:24Z calltoconstruct $
	@copyright Copyright (c) 2005-2007 by Jared White & J. Max Wilson
	@copyright Copyright (c) 2008-2009 by Joseph Woolley, Steffen Konerow, Jared White  & J. Max Wilson
	@license http://www.xajaxproject.org/bsd_license.txt BSD License
*/

function multiply($x, $y)
{
	$objResponse = new xajaxResponse();
	$objResponse->assign("z", "value", $x*$y);
	return $objResponse;
}

require("multiply.common.php");
$xajax->processRequest();
?>


text:
<?php

namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\User;
use Illuminate\Http\Request;
use Session;

class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\View\View
     */
    public function index()
    {
        $user = User::paginate(25);

        return view('user.index', compact('user'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\View\View
     */
    public function create()
    {
        return view('user.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param \Illuminate\Http\Request $request
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     */
    public function store(Request $request)
    {

        $requestData = $request->all();

        User::create($requestData);

        Session::flash('flash_message', 'User added!');

        return redirect('user');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     *
     * @return \Illuminate\View\View
     */
    public function show($id)
    {
        $user = User::findOrFail($id);

        return view('user.show', compact('user'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     *
     * @return \Illuminate\View\View
     */
    public function edit($id)
    {
        $user = User::findOrFail($id);

        return view('user.edit', compact('user'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @param \Illuminate\Http\Request $request
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     */
    public function update($id, Request $request)
    {

        $requestData = $request->all();

        $user = User::findOrFail($id);
        $user->update($requestData);

        Session::flash('flash_message', 'User updated!');

        return redirect('user');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     */
    public function destroy($id)
    {
        User::destroy($id);

        Session::flash('flash_message', 'User deleted!');

        return redirect('user');
    }
}


text:
<!DOCTYPE html>

    <title>Music Categories</title>
    <link href="Styles/P02MusicCategories.css" rel="stylesheet" />

        Music Categories

Even more websites all about website templates on Just Web Templates.

            <input class="add-button" type="button" value="Add" />
            <input class="listen-button" type="button" value="Listen" />

If you're looking for beautifull and professionaly made templates you can find them at Template Beauty.

            <input class="add-button" type="button" value="Add" />
            <input class="listen-button" type="button" value="Listen" />

You can remove any link to our websites from this template you're free to use the template without linking back to us.

            <input class="add-button" type="button" value="Add" />
            <input class="listen-button" type="button" value="Listen" />


text:
require 'java_buildpack'

module JavaBuildpack

  # A module encapsulating the logging for the Java buildpack
  module Logging
  end

end


text:
/*
 * Created by IntelliJ IDEA.
 * User: max
 * Date: Apr 19, 2002
 * Time: 1:51:41 PM
 * To change template for new class use
 * Code Style | Class Templates options (Tools | IDE Options).
 */
package com.intellij.openapi.editor.impl;

import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.openapi.editor.actionSystem.EditorActionManager;
import com.intellij.openapi.editor.actions.EditorActionUtil;
import com.intellij.openapi.editor.colors.EditorColors;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.event.SelectionEvent;
import com.intellij.openapi.editor.event.SelectionListener;
import com.intellij.openapi.editor.ex.DocumentEx;
import com.intellij.openapi.editor.ex.PrioritizedDocumentListener;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.EmptyClipboardOwner;
import org.jetbrains.annotations.NotNull;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.util.concurrent.CopyOnWriteArrayList;

public class SelectionModelImpl implements SelectionModel, PrioritizedDocumentListener {
  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.SelectionModelImpl");

  private final CopyOnWriteArrayList<SelectionListener> mySelectionListeners = ContainerUtil.createEmptyCOWList();
  private MyRangeMarker mySelectionMarker = null;
  private final EditorImpl myEditor;
  private int myLastSelectionStart;
  private LogicalPosition myBlockStart;
  private LogicalPosition myBlockEnd;
  private TextAttributes myTextAttributes;
  private boolean myIsInUpdate;

  private class MyRangeMarker extends RangeMarkerImpl {
    private boolean myIsReleased;

    private MyRangeMarker(DocumentEx document, int start, int end) {
      super(document, start, end);
      myIsReleased = false;
    }

    public void release() {
      myIsReleased = true;
    }

    public void documentChanged(DocumentEvent e) {
      if (myIsReleased) return;
      int startBefore = getStartOffset();
      int endBefore = getEndOffset();
      super.documentChanged(e);

      if (!isValid()) {
        myLastSelectionStart = myEditor.getCaretModel().getOffset();
        release();
        mySelectionMarker = null;
        fireSelectionChanged(startBefore, endBefore, myLastSelectionStart, myLastSelectionStart);
        return;
      }

      if (startBefore != getStartOffset() || endBefore != getStartOffset()) {
        fireSelectionChanged(startBefore, endBefore, getStartOffset(), getEndOffset());
      }
    }

    protected void registerInDocument() {
    }
  }

  public void beforeDocumentChange(DocumentEvent event) {
    myIsInUpdate = true;
  }

  public void documentChanged(DocumentEvent event) {
    myIsInUpdate = false;
    if (mySelectionMarker != null && mySelectionMarker.isValid()) {
      mySelectionMarker.documentChanged(event);
    }
  }

  public int getPriority() {
    return 4;
  }

  public SelectionModelImpl(EditorImpl editor) {
    myEditor = editor;
  }

  public int getSelectionStart() {
    validateContext(false);
    if (!hasSelection()) return myEditor.getCaretModel().getOffset();
    return mySelectionMarker.getStartOffset();
  }

  private void validateContext(boolean isWrite) {
    if (isWrite) {
      ApplicationManager.getApplication().assertIsDispatchThread();
    }
    else {
      ApplicationManager.getApplication().assertReadAccessAllowed();
    }
    LOG.assertTrue(!myIsInUpdate, "Selection model is in its update stage. All requests are illegal at this point.");
  }

  public int getSelectionEnd() {
    validateContext(false);
    if (!hasSelection()) return myEditor.getCaretModel().getOffset();
    return mySelectionMarker.getEndOffset();
  }

  public boolean hasSelection() {
    validateContext(false);
    if (mySelectionMarker != null && !mySelectionMarker.isValid()) {
      removeSelection();
    }

    return mySelectionMarker != null;
  }

  public void setSelection(int startOffset, int endOffset) {
    validateContext(true);

    removeBlockSelection();
    Document doc = myEditor.getDocument();

    if (startOffset < 0 || startOffset > doc.getTextLength()) {
      LOG.error("Wrong startOffset: " + startOffset);
    }
    if (endOffset < 0 || endOffset > doc.getTextLength()) {
      LOG.error("Wrong endOffset: " + endOffset);
    }

    myLastSelectionStart = startOffset;
    if (startOffset == endOffset) {
      removeSelection();
      return;
    }

    /* Normalize selection */
    if (startOffset > endOffset) {
      int tmp = startOffset;
      startOffset = endOffset;
      endOffset = tmp;
    }

    if (!GraphicsEnvironment.isHeadless()) {
      final Toolkit toolkit = myEditor.getComponent().getToolkit();
      Clipboard clip = toolkit.getSystemSelection();
      if (clip != null) {
        clip.setContents(new StringSelection(getSelectedText()), EmptyClipboardOwner.INSTANCE);
      }
    }

    int oldSelectionStart;
    int oldSelectionEnd;

    if (hasSelection()) {
      oldSelectionStart = mySelectionMarker.getStartOffset();
      oldSelectionEnd = mySelectionMarker.getEndOffset();
      if (oldSelectionStart == startOffset && oldSelectionEnd == endOffset) return;
    }
    else {
      oldSelectionStart = oldSelectionEnd = myEditor.getCaretModel().getOffset();
    }

    if (mySelectionMarker != null) {
      mySelectionMarker.release();
    }

    mySelectionMarker = new MyRangeMarker((DocumentEx)doc, startOffset, endOffset);

    fireSelectionChanged(oldSelectionStart, oldSelectionEnd, startOffset, endOffset);
  }

  private void fireSelectionChanged(int oldSelectionStart, int oldSelectionEnd, int startOffset, int endOffset) {
    repaintBySelectionChange(oldSelectionStart, startOffset, oldSelectionEnd, endOffset);

    SelectionEvent event = new SelectionEvent(myEditor,
                                              oldSelectionStart, oldSelectionEnd,
                                              startOffset, endOffset);

    for (SelectionListener listener : mySelectionListeners) {
      try {
        listener.selectionChanged(event);
      }
      catch (Exception e) {
        LOG.error(e);
      }
    }
  }

  private void repaintBySelectionChange(int oldSelectionStart, int startOffset, int oldSelectionEnd, int endOffset) {
    myEditor.repaint(Math.min(oldSelectionStart, startOffset), Math.max(oldSelectionStart, startOffset));
    myEditor.repaint(Math.min(oldSelectionEnd, endOffset), Math.max(oldSelectionEnd, endOffset));
  }

  public void setBlockSelection(LogicalPosition blockStart, LogicalPosition blockEnd) {
    removeSelection();

    int oldStartLine = 0;
    int oldEndLine = 0;

    if (hasBlockSelection()) {
      oldStartLine = myBlockStart.line;
      oldEndLine = myBlockEnd.line;
      if (oldStartLine > oldEndLine) {
        int t = oldStartLine;
        oldStartLine = oldEndLine;
        oldEndLine = t;
      }
    }

    int newStartLine = blockStart.line;
    int newEndLine = blockEnd.line;

    if (newStartLine > newEndLine) {
      int t = newStartLine;
      newStartLine = newEndLine;
      newEndLine = t;
    }

    myEditor.repaintLines(Math.min(oldStartLine, newStartLine), Math.max(newEndLine, oldEndLine));
    myBlockStart = blockStart;
    myBlockEnd = blockEnd;
  }

  public void removeSelection() {
    validateContext(true);
    removeBlockSelection();
    myLastSelectionStart = myEditor.getCaretModel().getOffset();
    if (mySelectionMarker != null) {
      int startOffset = mySelectionMarker.getStartOffset();
      int endOffset = mySelectionMarker.getEndOffset();
      mySelectionMarker.release();
      mySelectionMarker = null;
      fireSelectionChanged(startOffset, endOffset, myLastSelectionStart, myLastSelectionStart);
    }
  }

  public void removeBlockSelection() {
    if (hasBlockSelection()) {
      myEditor.repaint(0, myEditor.getDocument().getTextLength());
      myBlockStart = null;
      myBlockEnd = null;
    }
  }

  public boolean hasBlockSelection() {
    return myBlockStart != null;
  }

  public LogicalPosition getBlockStart() {
    return myBlockStart;
  }

  public LogicalPosition getBlockEnd() {
    return myBlockEnd;
  }

  public boolean isBlockSelectionGuarded() {
    if (!hasBlockSelection()) return false;
    int[] starts = getBlockSelectionStarts();
    int[] ends = getBlockSelectionEnds();
    Document doc = myEditor.getDocument();
    for (int i = 0; i < starts.length; i++) {
      int start = starts[i];
      int end = ends[i];
      if (start == end && doc.getOffsetGuard(start) != null || start != end && doc.getRangeGuard(start, end) != null) {
        return true;
      }
    }
    return false;
  }

  public RangeMarker getBlockSelectionGuard() {
    if (!hasBlockSelection()) return null;

    int[] starts = getBlockSelectionStarts();
    int[] ends = getBlockSelectionEnds();
    Document doc = myEditor.getDocument();
    for (int i = 0; i < starts.length; i++) {
      int start = starts[i];
      int end = ends[i];
      if (start == end) {
        RangeMarker guard = doc.getOffsetGuard(start);
        if (guard != null) return guard;
      }
      if (start != end) {
        RangeMarker guard = doc.getRangeGuard(start, end);
        if (guard != null) return guard;
      }
    }

    return null;
  }

  @NotNull
  public int[] getBlockSelectionStarts() {
    if (hasSelection()) {
      return new int[]{getSelectionStart()};
    }
    if (!hasBlockSelection()) {
      return ArrayUtil.EMPTY_INT_ARRAY;
    }

    int lineCount = Math.abs(myBlockEnd.line - myBlockStart.line) + 1;
    int startLine = Math.min(myBlockStart.line, myBlockEnd.line);

    int startColumn = Math.min(myBlockStart.column, myBlockEnd.column);

    int[] res = new int[lineCount];
    for (int i = startLine; i < startLine + lineCount; i++) {
      res[i - startLine] = myEditor.logicalPositionToOffset(new LogicalPosition(i, startColumn));
    }

    return res;
  }

  @NotNull
  public int[] getBlockSelectionEnds() {
    if (hasSelection()) {
      return new int[]{getSelectionEnd()};
    }

    if (!hasBlockSelection()) {
      return ArrayUtil.EMPTY_INT_ARRAY;
    }

    int lineCount = Math.abs(myBlockEnd.line - myBlockStart.line) + 1;
    int startLine = Math.min(myBlockStart.line, myBlockEnd.line);

    int startColumn = Math.min(myBlockStart.column, myBlockEnd.column);
    int columnCount = Math.abs(myBlockEnd.column - myBlockStart.column);

    int[] res = new int[lineCount];
    for (int i = startLine; i < startLine + lineCount; i++) {
      res[i - startLine] = myEditor.logicalPositionToOffset(new LogicalPosition(i, startColumn + columnCount));
    }

    return res;
  }

  public void addSelectionListener(SelectionListener listener) {
    mySelectionListeners.add(listener);
  }

  public void removeSelectionListener(SelectionListener listener) {
    boolean success = mySelectionListeners.remove(listener);
    LOG.assertTrue(success);
  }

  public String getSelectedText() {
    validateContext(false);
    if (!hasSelection() && !hasBlockSelection()) return null;

    CharSequence text = myEditor.getDocument().getCharsSequence();
    if (hasBlockSelection()) {
      int[] starts = getBlockSelectionStarts();
      int[] ends = getBlockSelectionEnds();
      int width = Math.abs(myBlockEnd.column - myBlockStart.column);
      final StringBuffer buf = new StringBuffer();
      for (int i = 0; i < starts.length; i++) {
        if (i > 0) buf.append('\n');
        final int len = ends[i] - starts[i];
        appendCharSequence(buf, text, starts[i], len);
        for (int j = len; j < width; j++) buf.append(' ');
      }
      return buf.toString();
    }

    int selectionStart = getSelectionStart();
    int selectionEnd = getSelectionEnd();
    return text.subSequence(selectionStart, selectionEnd).toString();
  }

  private static void appendCharSequence(@NotNull StringBuffer buf, @NotNull CharSequence s, int srcOffset, int len) {
    if (srcOffset < 0 || len < 0 || srcOffset > s.length() - len) {
      throw new IndexOutOfBoundsException("srcOffset " + srcOffset + ", len " + len + ", s.length() " + s.length());
    }
    if (len == 0) {
      return;
    }
    final int limit = srcOffset + len;
    for (int i = srcOffset; i < limit; i++){
      buf.append(s.charAt(i));
    }
  }

  public int getLeadSelectionOffset() {
    validateContext(false);
    int caretOffset = myEditor.getCaretModel().getOffset();
    if (!hasSelection()) return caretOffset;
    int startOffset = mySelectionMarker.getStartOffset();
    int endOffset = mySelectionMarker.getEndOffset();
    if (caretOffset == endOffset) return startOffset;
    return endOffset;
  }

  public void selectLineAtCaret() {
    validateContext(true);
    int lineNumber = myEditor.getCaretModel().getLogicalPosition().line;
    Document document = myEditor.getDocument();
    if (lineNumber >= document.getLineCount()) {
      return;
    }

    VisualPosition caret = myEditor.getCaretModel().getVisualPosition();
    LogicalPosition lineStart = myEditor.visualToLogicalPosition(new VisualPosition(caret.line, 0));
    LogicalPosition nextLineStart = myEditor.visualToLogicalPosition(new VisualPosition(caret.line + 1, 0));

    int start = myEditor.logicalPositionToOffset(lineStart);
    int end = myEditor.logicalPositionToOffset(nextLineStart);

    //myEditor.getCaretModel().moveToOffset(start);
    myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
    myEditor.getSelectionModel().removeSelection();
    myEditor.getSelectionModel().setSelection(start, end);
  }

  public void selectWordAtCaret(boolean honorCamelWordsSettings) {
    validateContext(true);
    removeSelection();
    final EditorSettings settings = myEditor.getSettings();
    boolean camelTemp = settings.isCamelWords();

    final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings;
    if (needOverrideSetting) {
      settings.setCamelWords(false);
    }

    EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(
      IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
    handler.execute(myEditor, myEditor.getDataContext());

    if (needOverrideSetting) {
      settings.setCamelWords(camelTemp);
    }
  }

  int getWordAtCaretStart() {
    Document document = myEditor.getDocument();
    int offset = myEditor.getCaretModel().getOffset();
    if (offset == 0) return 0;
    int lineNumber = myEditor.getCaretModel().getLogicalPosition().line;
    CharSequence text = document.getCharsSequence();
    int newOffset = offset - 1;
    int minOffset = lineNumber > 0 ? document.getLineEndOffset(lineNumber - 1) : 0;
    boolean camel = myEditor.getSettings().isCamelWords();
    for (; newOffset > minOffset; newOffset--) {
      if (EditorActionUtil.isWordStart(text, newOffset, camel)) break;
    }

    return newOffset;
  }

  int getWordAtCaretEnd() {
    Document document = myEditor.getDocument();
    int offset = myEditor.getCaretModel().getOffset();

    CharSequence text = document.getCharsSequence();
    if (offset >= document.getTextLength() - 1 || document.getLineCount() == 0) return offset;

    int newOffset = offset + 1;

    int lineNumber = myEditor.getCaretModel().getLogicalPosition().line;
    int maxOffset = document.getLineEndOffset(lineNumber);
    if (newOffset > maxOffset) {
      if (lineNumber + 1 >= document.getLineCount()) return offset;
      maxOffset = document.getLineEndOffset(lineNumber + 1);
    }
    boolean camel = myEditor.getSettings().isCamelWords();
    for (; newOffset < maxOffset; newOffset++) {
      if (EditorActionUtil.isWordEnd(text, newOffset, camel)) break;
    }

    return newOffset;
  }

  public void copySelectionToClipboard() {
    validateContext(true);
    String s = myEditor.getSelectionModel().getSelectedText();
    if (s == null) return;

    s = StringUtil.convertLineSeparators(s);
    StringSelection contents = new StringSelection(s);

    Project project = PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myEditor.getContentComponent()));
    if (project == null) {
      Clipboard clipboard = myEditor.getComponent().getToolkit().getSystemClipboard();
      clipboard.setContents(contents, EmptyClipboardOwner.INSTANCE);
    }
    else {
      CopyPasteManager.getInstance().setContents(contents);
    }
  }

  public TextAttributes getTextAttributes() {
    if (myTextAttributes == null) {
      myTextAttributes = new TextAttributes();
      EditorColorsScheme scheme = myEditor.getColorsScheme();
      myTextAttributes.setForegroundColor(scheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR));
      myTextAttributes.setBackgroundColor(scheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR));
    }

    return myTextAttributes;
  }

  public void reinitSettings() {
    myTextAttributes = null;
  }
}