text:
<?php

defined('JPATH_PLATFORM') or die;

/**
 * Joomla Platform Object Class
 *
 * This class allows for simple but smart objects with get and set methods
 * and an internal error handler.
 *
 * @package     Joomla.Platform
 * @subpackage  Object
 * @since       11.1
 */
class JObject
{
	/**
	 * An array of error messages or Exception objects.
	 *
	 * @var    array
	 * @since  11.1
	 * @see     JError
	 * @deprecated 12.3  JError has been deprecated
	 */
	protected $_errors = array();

	/**
	 * Class constructor, overridden in descendant classes.
	 *
	 * @param   mixed  $properties  Either and associative array or another
	 *                              object to set the initial properties of the object.
	 *
	 * @since   11.1
	 */
	public function __construct($properties = null)
	{
		if ($properties !== null)
		{
			$this->setProperties($properties);
		}
	}

	/**
	 * Magic method to convert the object to a string gracefully.
	 *
	 * @return  string  The classname.
	 *
	 * @since   11.1
	 * @deprecated 12.3  Classes should provide their own __toString() implementation.
	 */
	public function __toString()
	{
		return get_class($this);
	}

	/**
	 * Sets a default value if not alreay assigned
	 *
	 * @param   string  $property  The name of the property.
	 * @param   mixed   $default   The default value.
	 *
	 * @return  mixed
	 *
	 * @since   11.1
	 */
	public function def($property, $default = null)
	{
		$value = $this->get($property, $default);
		return $this->set($property, $value);
	}

	/**
	 * Returns a property of the object or the default value if the property is not set.
	 *
	 * @param   string  $property  The name of the property.
	 * @param   mixed   $default   The default value.
	 *
	 * @return  mixed    The value of the property.
	 *
	 * @since   11.1
	 *
	 * @see     getProperties()
	 */
	public function get($property, $default = null)
	{
		if (isset($this->$property))
		{
			return $this->$property;
		}
		return $default;
	}

	/**
	 * Returns an associative array of object properties.
	 *
	 * @param   boolean  $public  If true, returns only the public properties.
	 *
	 * @return  array
	 *
	 * @since   11.1
	 *
	 * @see     get()
	 */
	public function getProperties($public = true)
	{
		$vars = get_object_vars($this);
		if ($public)
		{
			foreach ($vars as $key => $value)
			{
				if ('_' == substr($key, 0, 1))
				{
					unset($vars[$key]);
				}
			}
		}

		return $vars;
	}

	/**
	 * Get the most recent error message.
	 *
	 * @param   integer  $i         Option error index.
	 * @param   boolean  $toString  Indicates if JError objects should return their error message.
	 *
	 * @return  string   Error message
	 *
	 * @since   11.1
	 * @see     JError
	 * @deprecated 12.3  JError has been deprecated
	 */
	public function getError($i = null, $toString = true)
	{
		// Find the error
		if ($i === null)
		{
			// Default, return the last message
			$error = end($this->_errors);
		}
		elseif (!array_key_exists($i, $this->_errors))
		{
			// If $i has been specified but does not exist, return false
			return false;
		}
		else
		{
			$error = $this->_errors[$i];
		}

		// Check if only the string is requested
		if ($error instanceof Exception && $toString)
		{
			return (string) $error;
		}

		return $error;
	}

	/**
	 * Return all errors, if any.
	 *
	 * @return  array  Array of error messages or JErrors.
	 *
	 * @since   11.1
	 * @see     JError
	 * @deprecated 12.3  JError has been deprecated
	 */
	public function getErrors()
	{
		return $this->_errors;
	}

	/**
	 * Modifies a property of the object, creating it if it does not already exist.
	 *
	 * @param   string  $property  The name of the property.
	 * @param   mixed   $value     The value of the property to set.
	 *
	 * @return  mixed  Previous value of the property.
	 *
	 * @since   11.1
	 */
	public function set($property, $value = null)
	{
		$previous = isset($this->$property) ? $this->$property : null;
		$this->$property = $value;
		return $previous;
	}

	/**
	 * Set the object properties based on a named array/hash.
	 *
	 * @param   mixed  $properties  Either an associative array or another object.
	 *
	 * @return  boolean
	 *
	 * @since   11.1
	 *
	 * @see     set()
	 */
	public function setProperties($properties)
	{
		if (is_array($properties) || is_object($properties))
		{
			foreach ((array) $properties as $k => $v)
			{
				// Use the set function which might be overridden.
				$this->set($k, $v);
			}
			return true;
		}

		return false;
	}

	/**
	 * Add an error message.
	 *
	 * @param   string  $error  Error message.
	 *
	 * @return  void
	 *
	 * @since   11.1
	 * @see     JError
	 * @deprecated 12.3  JError has been deprecated
	 */
	public function setError($error)
	{
		array_push($this->_errors, $error);
	}
}


text:
#ifndef DEVICE_STATS
#define DEVICE_STATS

#if Tensile_RUNTIME_LANGUAGE_HIP

#include "TensileTypes.h"
#include <hip/hip_runtime_api.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <regex>
#include <dirent.h>

#define WARNING(msg) std::cerr << "[!WARNING!] " << msg << std::endl;
#define FATAL(msg) {std::cerr << "[!FATAL!] " << msg << std::endl; exit(EXIT_FAILURE);} while(0)
#define INFO(msg) std::cout << "[INFO] " << msg << std::endl;

namespace tensile {

std::vector<std::string> split(const std::string& str, char sep) {
  std::vector<std::string> strings;
  std::istringstream f(str);
  std::string s;
  while (std::getline(f, s, sep)) {
    strings.push_back(s);
  }
  return strings;
}

std::vector<std::string> lsDir(const std::string& dname) {
  std::vector<std::string> files;
  struct dirent* entry;
  DIR *dir = opendir(dname.c_str());
  if (dir == NULL) {
    return files;
  }

  while ((entry = readdir(dir)) != NULL) {
    std::string fname(entry->d_name);
    if (fname != "." && fname != "..")
      files.push_back(fname);
  }
  return files;
}

std::vector<std::string> lsDir(const std::string& dname, const std::regex& match) {
  std::vector<std::string> files;
  struct dirent* entry;
  DIR *dir = opendir(dname.c_str());
  if (dir == NULL) {
    return files;
  }

  while ((entry = readdir(dir)) != NULL) {
    std::string fname(entry->d_name);
    if (fname != "." && fname != "..") {
      if (std::regex_match(fname, match)) {
        files.push_back(fname);
      }
    }
  }
  return files;
}

int readCurrentMhz(const std::string& fname) {
  std::ifstream f(fname);
  std::string line;
  while (std::getline(f, line)) {
    if (line.back() == '*') {
      std::string mhzstr = line.substr(3, line.size()-3-5);
      std::istringstream iss(mhzstr);
      int mhz;
      iss >> mhz;
      return mhz;
    }
  }
  return -1;
}

struct Device {
  int hipId;
  hipDeviceProp_t hipProps;
  std::string drmPath;
  std::string hwmonPath;

  /// Find the sysfs paths given that the device is initalized by hipGetDeviceProperties
  /// The paths are found using hiDeviceProp_t::pciBusID
  void initSysPaths() {
    bool found = false;
    for (std::string cardname : lsDir("/sys/class/drm", std::regex("card\\d+"))) {
      std::string carddir = "/sys/class/drm/" + cardname;
      std::string fname = carddir + "/device/uevent";
      std::ifstream f(fname);
      if (f.good() && f.is_open()) {
        std::string line;
        while (std::getline(f, line)) {
          if (split(line, '=')[0] == "PCI_SLOT_NAME") {
            std::string pciids = split(line, '=')[1];
            std::vector<std::string> ids = split(pciids, ':');
            //std::string busid = "0x" + ids[1];
            int pciBusId = std::stoul("0x" + ids[1], nullptr, 16);
            if (pciBusId == hipProps.pciBusID) {
              drmPath = carddir;
              // find hwmon path
              std::vector<std::string> hwpaths = lsDir(drmPath + "/device/hwmon", std::regex("hwmon\\d+"));
              if (hwpaths.size() != 1) {
                WARNING("No or multiple hwmon paths for " << drmPath);
              }
              if (hwpaths.size() > 0) {
                hwmonPath = drmPath + "/device/hwmon/" + hwpaths[0];
              }
              found = true;
            }
            break;
          }
        }
      }
      if (found)
        break;
    }
    if (!found) {
      WARNING("Can't find sysfs path for device " << hipId);
    }
  }

  void printInfo() {
    // print out device info
    INFO("Device " << hipId << ": " << hipProps.name);
    INFO("\tArch:\t" << hipProps.gcnArch)
    INFO("\tGMem:\t" << hipProps.totalGlobalMem/1024/1024 << " MiB");
    INFO("\twarps:\t" << hipProps.warpSize);
    INFO("\tCUs:\t" << hipProps.multiProcessorCount);
    INFO("\tMaxClk:\t" << hipProps.clockRate);
    INFO("\tMemClk:\t" << hipProps.memoryClockRate);
    INFO("\tdrm:\t" << drmPath);
    INFO("\thwmon:\t" << hwmonPath);
    //INFO("\t\tpciDomainID:\t" << hipProps.pciDomainID);
    //INFO("\t\tpciBusID:\t" << hipProps.pciBusID);
    //INFO("\t\tpciDeviceID:\t" << hipProps.pciDeviceID);
  }

  float getTemp() {
    std::ifstream f(hwmonPath + "/temp1_input");
    //std::ifstream f("/sys/class/hwmon/hwmon0/temp1_input");
    int temp;
    f >> temp;
    return temp / 1000.f; // temp is in milli celsius
  }

  int getFanSpeed() {
    //std::ifstream f("/sys/class/hwmon/hwmon0/pwm1");
    std::ifstream f(hwmonPath + "/pwm1");
    int fan;
    f >> fan;
    return fan;
  }

  int getCoreClock() {
    return readCurrentMhz(drmPath + "/device/pp_dpm_sclk");
  }

  int getMemClock() {
    return readCurrentMhz(drmPath + "/device/pp_dpm_mclk");
  }
};

struct Devices {
  static std::vector<Device>& getDevices(bool fromInit = false) {
    static bool isInit = false;
    static std::vector<Device> d;
    if (!isInit) {
      isInit = true;
      if (!fromInit)
        initDevices();
    }
    return d;
  }

  static Device& getDefaultDevice() {
    if (getDevices().size() == 0) {
      FATAL("No HIP Devices available.");
    }
    return getDevices()[0];
  }

  static void initDevices() {
    int devcount;
    tensileStatusCheck(hipGetDeviceCount(&devcount));
    //INFO("Number of HIP devices found: " << devcount);

    if (devcount == 0) {
      FATAL("No HIP devices found.");
    }

    std::vector<Device>& devs = getDevices(true);
    devs.resize(devcount);

    // init and get devices
    for (int d = 0; d < devcount; ++d) {
      devs[d].hipId = d;
      tensileStatusCheck(hipGetDeviceProperties(&devs[d].hipProps, d/*deviceID*/));
      devs[d].initSysPaths();
      //devs[d].printInfo();
    }

  }

};
} // namespace tensile
#endif

void tensileInitDeviceStats() {
#if Tensile_RUNTIME_LANGUAGE_HIP
  tensile::Devices::initDevices();
#endif
}

float tensileGetDeviceTemp(unsigned int deviceId) {
#if Tensile_RUNTIME_LANGUAGE_HIP
  return tensile::Devices::getDevices()[deviceId].getTemp();
#else
  return -1;
#endif
}

int tensileGetDeviceFanSpeed(unsigned int deviceId) {
#if Tensile_RUNTIME_LANGUAGE_HIP
  return tensile::Devices::getDevices()[deviceId].getFanSpeed();
#else
  return -1;
#endif
}

int tensileGetDeviceCoreClock(unsigned int deviceId) {
#if Tensile_RUNTIME_LANGUAGE_HIP
  return tensile::Devices::getDevices()[deviceId].getCoreClock();
#else
  return -1;
#endif
}

int tensileGetDeviceMemClock(unsigned int deviceId) {
#if Tensile_RUNTIME_LANGUAGE_HIP
  return tensile::Devices::getDevices()[deviceId].getMemClock();
#else
  return -1;
#endif
}

#endif // DEVICE_STATS

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace SilverStripe\IFrame;

use PageController;
use SilverStripe\Control\Director;
use SilverStripe\View\Requirements;

class IFramePageController extends PageController
{
    protected function init()
    {
        parent::init();
        $currentProtocol = Director::protocol();
        $desiredProtocol = $this->ForceProtocol;
        if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
            $enforcedLocation = preg_replace(
                "#^${currentProtocol}#",
                $desiredProtocol,
                $this->AbsoluteLink()
            );
            return $this->redirect($enforcedLocation);
        }

        if ($this->IFrameURL) {
            Requirements::javascript('silverstripe/iframe: javascript/iframe_page.js');
        }
    }
}


text:
@implementation MyFlowLayout

-(instancetype)initWithFrame:(CGRect)frame orientation:(MyOrientation)orientation arrangedCount:(NSInteger)arrangedCount
{
    self = [super initWithFrame:frame];
    if (self != nil)
    {
        self.myCurrentSizeClass.orientation = orientation;
        self.myCurrentSizeClass.arrangedCount = arrangedCount;
    }

    return  self;
}

-(instancetype)initWithOrientation:(MyOrientation)orientation arrangedCount:(NSInteger)arrangedCount
{
    return [self initWithFrame:CGRectZero orientation:orientation arrangedCount:arrangedCount];
}

+(instancetype)flowLayoutWithOrientation:(MyOrientation)orientation arrangedCount:(NSInteger)arrangedCount
{
    MyFlowLayout *layout = [[[self class] alloc] initWithOrientation:orientation arrangedCount:arrangedCount];
    return layout;
}

-(void)setOrientation:(MyOrientation)orientation
{
     MyFlowLayout *lsc = self.myCurrentSizeClass;
    if (lsc.orientation != orientation)
    {
        lsc.orientation = orientation;
        [self setNeedsLayout];
    }
}

-(MyOrientation)orientation
{
    return self.myCurrentSizeClass.orientation;
}

-(void)setArrangedCount:(NSInteger)arrangedCount
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;
    if (lsc.arrangedCount != arrangedCount)
    {
        lsc.arrangedCount = arrangedCount;
        [self setNeedsLayout];
    }
}

-(NSInteger)arrangedCount
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;
    return lsc.arrangedCount;
}

-(NSInteger)pagedCount
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;
    return lsc.pagedCount;
}

-(void)setPagedCount:(NSInteger)pagedCount
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;
    if (lsc.pagedCount != pagedCount)
    {
        lsc.pagedCount = pagedCount;
        [self setNeedsLayout];
    }
}

-(void)setAutoArrange:(BOOL)autoArrange
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;

    if (lsc.autoArrange != autoArrange)
    {
        lsc.autoArrange = autoArrange;
        [self setNeedsLayout];
    }
}

-(BOOL)autoArrange
{
    return self.myCurrentSizeClass.autoArrange;
}

-(void)setArrangedGravity:(MyGravity)arrangedGravity
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;
    if (lsc.arrangedGravity != arrangedGravity)
    {
        lsc.arrangedGravity = arrangedGravity;
        [self setNeedsLayout];
    }
}

-(MyGravity)arrangedGravity
{
    return self.myCurrentSizeClass.arrangedGravity;
}

-(void)setSubviewsSize:(CGFloat)subviewSize minSpace:(CGFloat)minSpace maxSpace:(CGFloat)maxSpace
{
    [self setSubviewsSize:subviewSize minSpace:minSpace maxSpace:maxSpace inSizeClass:MySizeClass_hAny | MySizeClass_wAny];
}

-(void)setSubviewsSize:(CGFloat)subviewSize minSpace:(CGFloat)minSpace maxSpace:(CGFloat)maxSpace inSizeClass:(MySizeClass)sizeClass
{
    MyFlowLayoutViewSizeClass *lsc = (MyFlowLayoutViewSizeClass*)[self fetchLayoutSizeClass:sizeClass];
    lsc.subviewSize = subviewSize;
    lsc.maxSpace = maxSpace;
    lsc.minSpace = minSpace;
    [self setNeedsLayout];
}

#pragma mark -- Deprecated Method

-(void)setAverageArrange:(BOOL)averageArrange
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;

    if (lsc.orientation == MyOrientation_Vert)
    {
        if (averageArrange)
            lsc.gravity = (lsc.gravity & MyGravity_Horz_Mask) | MyGravity_Horz_Fill;
        else
            lsc.gravity = (lsc.gravity & MyGravity_Horz_Mask) | MyGravity_None;
    }
    else
    {
        if (averageArrange)
            lsc.gravity = (lsc.gravity & MyGravity_Vert_Mask) | MyGravity_Vert_Fill;
        else
            lsc.gravity = (lsc.gravity & MyGravity_Vert_Mask) | MyGravity_None;
    }

}

-(BOOL)averageArrange
{
    MyFlowLayout *lsc = self.myCurrentSizeClass;

    if (lsc.orientation == MyOrientation_Vert)
        return (lsc.gravity & MyGravity_Vert_Mask) == MyGravity_Horz_Fill;
    else
        return (lsc.gravity & MyGravity_Horz_Mask) == MyGravity_Vert_Fill;
}

#pragma mark -- Override Method

-(CGSize)calcLayoutRect:(CGSize)size isEstimate:(BOOL)isEstimate pHasSubLayout:(BOOL*)pHasSubLayout sizeClass:(MySizeClass)sizeClass sbs:(NSMutableArray*)sbs
{
    CGSize selfSize = [super calcLayoutRect:size isEstimate:isEstimate pHasSubLayout:pHasSubLayout sizeClass:sizeClass sbs:sbs];

    if (sbs == nil)
        sbs = [self myGetLayoutSubviews];

    MyFlowLayout *lsc = self.myCurrentSizeClass;

    MyOrientation orientation = lsc.orientation;
    MyGravity gravity = lsc.gravity;
    MyGravity arrangedGravity = lsc.arrangedGravity;

    for (UIView *sbv in sbs)
    {
        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (!isEstimate)
        {
            sbvmyFrame.frame = sbv.bounds;
            [self myCalcSizeOfWrapContentSubview:sbv sbvsc:sbvsc sbvmyFrame:sbvmyFrame selfLayoutSize:selfSize];
        }

        if ([sbv isKindOfClass:[MyBaseLayout class]])
        {

            if (sbvsc.wrapContentWidth)
            {
                if (lsc.pagedCount > 0 || sbvsc.widthSizeInner.dimeVal != nil ||
                    (orientation == MyOrientation_Horz && (arrangedGravity & MyGravity_Vert_Mask) == MyGravity_Horz_Fill) ||
                    (orientation == MyOrientation_Vert && ((gravity & MyGravity_Vert_Mask) == MyGravity_Horz_Fill || sbvsc.weight != 0)))
                {
                    sbvsc.wrapContentWidth = NO;
                }
            }

            if (sbvsc.wrapContentHeight)
            {
                if (lsc.pagedCount > 0 || sbvsc.heightSizeInner.dimeVal != nil ||
                    (orientation == MyOrientation_Vert && (arrangedGravity & MyGravity_Horz_Mask) == MyGravity_Vert_Fill) ||
                    (orientation == MyOrientation_Horz && ((gravity & MyGravity_Horz_Mask) == MyGravity_Vert_Fill || sbvsc.weight != 0)))
                {
                    sbvsc.wrapContentHeight = NO;
                }
            }

            BOOL isSbvWrap = sbvsc.wrapContentHeight || sbvsc.wrapContentWidth;

            if (pHasSubLayout != nil && isSbvWrap)
                *pHasSubLayout = YES;

            if (isEstimate && isSbvWrap)
            {
                [(MyBaseLayout*)sbv sizeThatFits:sbvmyFrame.frame.size inSizeClass:sizeClass];
                if (sbvmyFrame.multiple)
                {
                    sbvmyFrame.sizeClass = [sbv myBestSizeClass:sizeClass]; //因为sizeThatFits执行后会还原,所以这里要重新设置
                    sbvsc = sbvmyFrame.sizeClass;
                }
            }
        }
    }

    if (orientation == MyOrientation_Vert)
    {
        if (lsc.arrangedCount == 0)
            selfSize = [self myLayoutSubviewsForVertContent:selfSize sbs:sbs isEstimate:isEstimate lsc:lsc];
        else
            selfSize = [self myLayoutSubviewsForVert:selfSize sbs:sbs isEstimate:isEstimate lsc:lsc];
    }
    else
    {
        if (lsc.arrangedCount == 0)
            selfSize = [self myLayoutSubviewsForHorzContent:selfSize sbs:sbs isEstimate:isEstimate lsc:lsc];
        else
            selfSize = [self myLayoutSubviewsForHorz:selfSize sbs:sbs isEstimate:isEstimate lsc:lsc];
    }

    //调整布局视图自己的尺寸。
    [self myAdjustLayoutSelfSize:&selfSize lsc:lsc];
    //如果是反向则调整所有子视图的左右位置。
    [self myAdjustSubviewsRTLPos:sbs selfWidth:selfSize.width];

    return [self myAdjustSizeWhenNoSubviews:selfSize sbs:sbs lsc:lsc];
}

-(id)createSizeClassInstance
{
    return [MyFlowLayoutViewSizeClass new];
}

#pragma mark -- Private Method

- (void)myCalcVertLayoutSinglelineWeight:(CGSize)selfSize totalFloatWidth:(CGFloat)totalFloatWidth totalWeight:(CGFloat)totalWeight sbs:(NSArray *)sbs startIndex:(NSInteger)startIndex count:(NSInteger)count
{
    for (NSInteger j = startIndex - count; j < startIndex; j++)
    {
        UIView *sbv = sbs[j];
        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (sbvsc.weight != 0)
        {
            CGFloat tempWidth = (totalFloatWidth * sbvsc.weight / totalWeight);
            if (sbvsc.widthSizeInner != nil)
                tempWidth = [sbvsc.widthSizeInner measureWith:tempWidth];

            sbvmyFrame.width =  [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:tempWidth sbvSize:sbvmyFrame.frame.size selfLayoutSize:selfSize];
            sbvmyFrame.trailing = sbvmyFrame.leading + sbvmyFrame.width;
        }
    }
}

- (void)myCalcHorzLayoutSinglelineWeight:(CGSize)selfSize totalFloatHeight:(CGFloat)totalFloatHeight totalWeight:(CGFloat)totalWeight sbs:(NSArray *)sbs startIndex:(NSInteger)startIndex count:(NSInteger)count
{
    for (NSInteger j = startIndex - count; j < startIndex; j++)
    {
        UIView *sbv = sbs[j];
        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (sbvsc.weight != 0)
        {
            CGFloat tempHeight = (totalFloatHeight * sbvsc.weight / totalWeight);
            if (sbvsc.heightSizeInner != nil)
                tempHeight = [sbvsc.heightSizeInner measureWith:tempHeight];

            sbvmyFrame.height =  [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:tempHeight sbvSize:sbvmyFrame.frame.size selfLayoutSize:selfSize];
            sbvmyFrame.bottom = sbvmyFrame.top + sbvmyFrame.height;

            if (sbvsc.widthSizeInner.dimeRelaVal != nil && sbvsc.widthSizeInner.dimeRelaVal == sbvsc.heightSizeInner)
                sbvmyFrame.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:[sbvsc.widthSizeInner measureWith: sbvmyFrame.height ] sbvSize:sbvmyFrame.frame.size selfLayoutSize:selfSize];

        }
    }
}

- (void)myCalcVertLayoutSinglelineAlignment:(CGSize)selfSize rowMaxHeight:(CGFloat)rowMaxHeight rowMaxWidth:(CGFloat)rowMaxWidth horzGravity:(MyGravity)horzGravity vertAlignment:(MyGravity)vertAlignment sbs:(NSArray *)sbs startIndex:(NSInteger)startIndex count:(NSInteger)count vertSpace:(CGFloat)vertSpace horzSpace:(CGFloat)horzSpace isEstimate:(BOOL)isEstimate lsc:(MyFlowLayout*)lsc
{

    CGFloat paddingLeading = lsc.myLayoutLeadingPadding;
    CGFloat paddingTrailing = lsc.myLayoutTrailingPadding;
    CGFloat paddingHorz = paddingLeading + paddingTrailing;

    CGFloat addXPos = 0; //多出来的空隙区域,用于停靠处理。
    CGFloat addXFill = 0;  //多出来的平均区域,用于拉伸间距或者尺寸
    BOOL averageArrange = (horzGravity == MyGravity_Horz_Fill);

    if (!averageArrange || lsc.arrangedCount == 0)
    {
        switch (horzGravity) {
            case MyGravity_Horz_Center:
            {
                addXPos = (selfSize.width - paddingHorz - rowMaxWidth) / 2;
            }
                break;
            case MyGravity_Horz_Trailing:
            {
                addXPos = selfSize.width - paddingHorz - rowMaxWidth; //因为具有不考虑左边距,而原来的位置增加了左边距,因此
            }
                break;
            case MyGravity_Horz_Between:
            {
                //总宽度减去最大的宽度。再除以数量表示每个应该扩展的空间。最后一行无效(如果最后一行的数量和其他行的数量一样除外)。
                if ((startIndex != sbs.count || count == lsc.arrangedCount) && count > 1)
                {
                    addXFill = (selfSize.width - paddingHorz - rowMaxWidth) / (count - 1);
                }
            }
                break;
            default:
                break;
        }

        //处理内容拉伸的情况。这里是只有内容约束布局才支持尺寸拉伸。
        if (lsc.arrangedCount == 0 && averageArrange)
        {
            //不是最后一行。。
            if (startIndex != sbs.count)
            {
                addXFill = (selfSize.width - paddingHorz - rowMaxWidth) / count;
            }

        }
    }

    //将整行的位置进行调整。
    for (NSInteger j = startIndex - count; j < startIndex; j++)
    {
        UIView *sbv = sbs[j];

        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (!isEstimate && self.intelligentBorderline != nil)
        {
            if ([sbv isKindOfClass:[MyBaseLayout class]])
            {
                MyBaseLayout *sbvl = (MyBaseLayout*)sbv;
                if (!sbvl.notUseIntelligentBorderline)
                {
                    sbvl.leadingBorderline = nil;
                    sbvl.topBorderline = nil;
                    sbvl.trailingBorderline = nil;
                    sbvl.bottomBorderline = nil;

                    //如果不是最后一行就画下面,
                    if (startIndex != sbs.count)
                    {
                        sbvl.bottomBorderline = self.intelligentBorderline;
                    }

                    //如果不是最后一列就画右边,
                    if (j < startIndex - 1)
                    {
                        sbvl.trailingBorderline = self.intelligentBorderline;
                    }

                    //如果最后一行的最后一个没有满列数时
                    if (j == sbs.count - 1 && lsc.arrangedCount != count )
                    {
                        sbvl.trailingBorderline = self.intelligentBorderline;
                    }

                    //如果有垂直间距则不是第一行就画上
                    if (vertSpace != 0 && startIndex - count != 0)
                    {
                        sbvl.topBorderline = self.intelligentBorderline;
                    }

                    //如果有水平间距则不是第一列就画左
                    if (horzSpace != 0 && j != startIndex - count)
                    {
                        sbvl.leadingBorderline = self.intelligentBorderline;
                    }

                }
            }
        }

        MyGravity sbvVertAlignment = sbvsc.myAlignment & MyGravity_Horz_Mask;
        if (sbvVertAlignment != MyGravity_None)
            vertAlignment = sbvVertAlignment;

        if ((vertAlignment != MyGravity_None && vertAlignment != MyGravity_Vert_Top) || _myCGFloatNotEqual(addXPos, 0)  ||  _myCGFloatNotEqual(addXFill, 0))
        {

            sbvmyFrame.leading += addXPos;

            //内容约束布局并且是拉伸尺寸。。
            if (lsc.arrangedCount == 0 && averageArrange)
            {
                //只拉伸宽度不拉伸间距
                sbvmyFrame.width += addXFill;

                if (j != startIndex - count)
                {
                    sbvmyFrame.leading += addXFill * (j - (startIndex - count));

                }
            }
            else
            {
                //其他的只拉伸间距
                sbvmyFrame.leading += addXFill * (j - (startIndex - count));
            }

            switch (vertAlignment) {
                case MyGravity_Vert_Center:
                {
                    sbvmyFrame.top += (rowMaxHeight - sbvsc.topPosInner.absVal - sbvsc.bottomPosInner.absVal - sbvmyFrame.height) / 2;

                }
                    break;
                case MyGravity_Vert_Bottom:
                {
                    sbvmyFrame.top += rowMaxHeight - sbvsc.topPosInner.absVal - sbvsc.bottomPosInner.absVal - sbvmyFrame.height;
                }
                    break;
                case MyGravity_Vert_Fill:
                {
                    sbvmyFrame.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rowMaxHeight - sbvsc.topPosInner.absVal - sbvsc.bottomPosInner.absVal sbvSize:sbvmyFrame.frame.size selfLayoutSize:selfSize];
                }
                    break;
                default:
                    break;
            }
        }
    }

}

- (void)myCalcHorzLayoutSinglelineAlignment:(CGSize)selfSize colMaxWidth:(CGFloat)colMaxWidth colMaxHeight:(CGFloat)colMaxHeight vertGravity:(MyGravity)vertGravity  horzAlignment:(MyGravity)horzAlignment sbs:(NSArray *)sbs startIndex:(NSInteger)startIndex count:(NSInteger)count vertSpace:(CGFloat)vertSpace horzSpace:(CGFloat)horzSpace isEstimate:(BOOL)isEstimate lsc:(MyFlowLayout*)lsc
{

    CGFloat paddingTop = lsc.myLayoutTopPadding;
    CGFloat paddingBottom = lsc.myLayoutBottomPadding;
    CGFloat paddingVert = paddingTop + paddingBottom;

    CGFloat addYPos = 0;
    CGFloat addYFill = 0;

    BOOL averageArrange = (vertGravity == MyGravity_Vert_Fill);

    if (!averageArrange || lsc.arrangedCount == 0)
    {
        switch (vertGravity) {
            case MyGravity_Vert_Center:
            {
                addYPos = (selfSize.height - paddingVert - colMaxHeight) / 2;
            }
                break;
            case MyGravity_Vert_Bottom:
            {
                addYPos = selfSize.height - paddingVert - colMaxHeight;
            }
                break;
            case MyGravity_Vert_Between:
            {
                //总宽度减去最大的宽度。再除以数量表示每个应该扩展的空间。最后一行无效(如果数量和单行的数量相等除外)。
                if ((startIndex != sbs.count || count == lsc.arrangedCount) && count > 1)
                {
                    addYFill = (selfSize.height - paddingVert - colMaxHeight) / (count - 1);
                }

            }
            default:
                break;
        }

        //处理内容拉伸的情况。
        if (lsc.arrangedCount == 0 && averageArrange)
        {
            if (startIndex != sbs.count)
            {
                addYFill = (selfSize.height  - paddingVert - colMaxHeight) / count;
            }

        }

    }

    //将整行的位置进行调整。
    for (NSInteger j = startIndex - count; j < startIndex; j++)
    {
        UIView *sbv = sbs[j];
        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (!isEstimate && self.intelligentBorderline != nil)
        {
            if ([sbv isKindOfClass:[MyBaseLayout class]])
            {
                MyBaseLayout *sbvl = (MyBaseLayout*)sbv;
                if (!sbvl.notUseIntelligentBorderline)
                {
                    sbvl.leadingBorderline = nil;
                    sbvl.topBorderline = nil;
                    sbvl.trailingBorderline = nil;
                    sbvl.bottomBorderline = nil;

                    //如果不是最后一行就画下面,
                    if (j < startIndex - 1)
                    {
                        sbvl.bottomBorderline = self.intelligentBorderline;
                    }

                    //如果不是最后一列就画右边,
                    if (startIndex != sbs.count )
                    {
                        sbvl.trailingBorderline = self.intelligentBorderline;

                    }

                    //如果最后一行的最后一个没有满列数时
                    if (j == sbs.count - 1 && lsc.arrangedCount != count )
                    {
                        sbvl.bottomBorderline = self.intelligentBorderline;
                    }

                    //如果有垂直间距则不是第一行就画上
                    if (vertSpace != 0 && j != startIndex - count)
                    {
                        sbvl.topBorderline = self.intelligentBorderline;
                    }

                    //如果有水平间距则不是第一列就画左
                    if (horzSpace != 0 && startIndex - count != 0  )
                    {
                       sbvl.leadingBorderline = self.intelligentBorderline;

                    }

                }
            }
        }

        CGFloat sbvHorzAlignment = [self myConvertLeftRightGravityToLeadingTrailing:sbvsc.myAlignment & MyGravity_Vert_Mask];
        if (sbvHorzAlignment != MyGravity_None)
            horzAlignment = sbvHorzAlignment;

        if ((horzAlignment != MyGravity_None && horzAlignment != MyGravity_Horz_Leading) || _myCGFloatNotEqual(addYPos, 0) || _myCGFloatNotEqual(addYFill, 0) )
        {
            sbvmyFrame.top += addYPos;

            if (lsc.arrangedCount == 0 && averageArrange)
            {
                //只拉伸宽度不拉伸间距
                sbvmyFrame.height += addYFill;

                if (j != startIndex - count)
                {
                    sbvmyFrame.top += addYFill * (j - (startIndex - count));

                }
            }
            else
            {
                //只拉伸间距
                sbvmyFrame.top += addYFill * (j - (startIndex - count));
            }

            switch (horzAlignment) {
                case MyGravity_Horz_Center:
                {
                    sbvmyFrame.leading += (colMaxWidth - sbvsc.leadingPosInner.absVal - sbvsc.trailingPosInner.absVal - sbvmyFrame.width) / 2;

                }
                    break;
                case MyGravity_Horz_Trailing:
                {
                    sbvmyFrame.leading += colMaxWidth - sbvsc.leadingPosInner.absVal - sbvsc.trailingPosInner.absVal - sbvmyFrame.width;
                }
                    break;
                case MyGravity_Horz_Fill:
                {
                    sbvmyFrame.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:colMaxWidth - sbvsc.leadingPosInner.absVal - sbvsc.trailingPosInner.absVal sbvSize:sbvmyFrame.frame.size selfLayoutSize:selfSize];
                }
                    break;
                default:
                    break;
            }
        }
    }
}

-(CGFloat)myCalcSinglelineSize:(NSArray*)sbs space:(CGFloat)space
{
    CGFloat size = 0;
    for (UIView *sbv in sbs)
    {
        size += sbv.myFrame.trailing;
        if (sbv != sbs.lastObject)
            size += space;
    }

    return size;
}

-(NSArray*)myGetAutoArrangeSubviews:(NSMutableArray*)sbs selfSize:(CGFloat)selfSize space:(CGFloat)space
{

    NSMutableArray *retArray = [NSMutableArray arrayWithCapacity:sbs.count];

    NSMutableArray *bestSinglelineArray = [NSMutableArray arrayWithCapacity:sbs.count /2];

    while (sbs.count) {

        [self myCalcAutoArrangeSinglelineSubviews:sbs
                                          index:0
                                      calcArray:@[]
                                       selfSize:selfSize
                                         space:space
                            bestSinglelineArray:bestSinglelineArray];

        [retArray addObjectsFromArray:bestSinglelineArray];

        [bestSinglelineArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * stop) {
            [sbs removeObject:obj];
        }];

        [bestSinglelineArray removeAllObjects];
    }

    return retArray;
}

-(void)myCalcAutoArrangeSinglelineSubviews:(NSMutableArray*)sbs
                                   index:(NSInteger)index
                               calcArray:(NSArray*)calcArray
                                selfSize:(CGFloat)selfSize
                                  space:(CGFloat)space
                     bestSinglelineArray:(NSMutableArray*)bestSinglelineArray
{
    if (index >= sbs.count)
    {
        CGFloat s1 = [self myCalcSinglelineSize:calcArray space:space];
        CGFloat s2 = [self myCalcSinglelineSize:bestSinglelineArray space:space];
        if (_myCGFloatLess(fabs(selfSize - s1), fabs(selfSize - s2)) && _myCGFloatLessOrEqual(s1, selfSize) )
        {
            [bestSinglelineArray setArray:calcArray];
        }

        return;
    }

    for (NSInteger i = index; i < sbs.count; i++) {

        NSMutableArray *calcArray2 = [NSMutableArray arrayWithArray:calcArray];
        [calcArray2 addObject:sbs[i]];

        CGFloat s1 = [self myCalcSinglelineSize:calcArray2 space:space];
        if (_myCGFloatLessOrEqual(s1, selfSize))
        {
            CGFloat s2 = [self myCalcSinglelineSize:bestSinglelineArray space:space];
            if (_myCGFloatLess(fabs(selfSize - s1), fabs(selfSize - s2)))
            {
                [bestSinglelineArray setArray:calcArray2];
            }

            if (_myCGFloatEqual(s1, selfSize))
                break;

            [self myCalcAutoArrangeSinglelineSubviews:sbs
                                              index:i + 1
                                          calcArray:calcArray2
                                           selfSize:selfSize
                                             space:space
                                bestSinglelineArray:bestSinglelineArray];

        }
        else
            break;

    }

}

-(CGSize)myLayoutSubviewsForVertContent:(CGSize)selfSize sbs:(NSMutableArray*)sbs isEstimate:(BOOL)isEstimate lsc:(MyFlowLayout*)lsc
{

    CGFloat paddingTop = lsc.myLayoutTopPadding;
    CGFloat paddingBottom = lsc.myLayoutBottomPadding;
    CGFloat paddingLeading = lsc.myLayoutLeadingPadding;
    CGFloat paddingTrailing = lsc.myLayoutTrailingPadding;
    CGFloat paddingHorz = paddingLeading + paddingTrailing;

    CGFloat xPos = paddingLeading;
    CGFloat yPos = paddingTop;
    CGFloat rowMaxHeight = 0;  //某一行的最高值。
    CGFloat rowMaxWidth = 0;   //某一行的最宽值

    MyGravity vertGravity = lsc.gravity & MyGravity_Horz_Mask;
    MyGravity horzGravity = [self myConvertLeftRightGravityToLeadingTrailing:lsc.gravity & MyGravity_Vert_Mask];
    MyGravity vertAlign = lsc.arrangedGravity & MyGravity_Horz_Mask;

    //支持浮动水平间距。
    CGFloat vertSpace = lsc.subviewVSpace;
    CGFloat horzSpace = lsc.subviewHSpace;
    CGFloat subviewSize = ((MyFlowLayoutViewSizeClass*)self.myCurrentSizeClass).subviewSize;
    if (subviewSize != 0)
    {

        CGFloat minSpace = ((MyFlowLayoutViewSizeClass*)self.myCurrentSizeClass).minSpace;
        CGFloat maxSpace = ((MyFlowLayoutViewSizeClass*)self.myCurrentSizeClass).maxSpace;

        NSInteger rowCount =  floor((selfSize.width - paddingHorz  + minSpace) / (subviewSize + minSpace));
        if (rowCount > 1)
        {
            horzSpace = (selfSize.width - paddingHorz - subviewSize * rowCount)/(rowCount - 1);
            if (_myCGFloatGreat(horzSpace, maxSpace))
            {
                horzSpace = maxSpace;

                subviewSize =  (selfSize.width - paddingHorz -  horzSpace * (rowCount - 1)) / rowCount;

            }
        }
    }

    if (lsc.autoArrange)
    {
        //计算出每个子视图的宽度。
        for (UIView* sbv in sbs)
        {
            MyFrame *sbvmyFrame = sbv.myFrame;
            UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

#ifdef DEBUG
            //约束异常:垂直流式布局设置autoArrange为YES时,子视图不能将weight设置为非0.
            NSCAssert(sbvsc.weight == 0, @"Constraint exception!! vertical flow layout:%@ 's subview:%@ can't set weight when the autoArrange set to YES",self, sbv);
#endif
            CGFloat leadingSpace = sbvsc.leadingPosInner.absVal;
            CGFloat trailingSpace = sbvsc.trailingPosInner.absVal;
            CGRect rect = sbvmyFrame.frame;

            if (sbvsc.widthSizeInner.dimeNumVal != nil)
                rect.size.width = sbvsc.widthSizeInner.measure;

            [self mySetSubviewRelativeDimeSize:sbvsc.widthSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

            rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:rect.size.width sbvSize:rect.size selfLayoutSize:selfSize];

            //暂时把宽度存放sbv.myFrame.trailing上。因为浮动布局来说这个属性无用。
            sbvmyFrame.trailing = leadingSpace + rect.size.width + trailingSpace;
            if (_myCGFloatGreat(sbvmyFrame.trailing, selfSize.width - paddingHorz))
                sbvmyFrame.trailing = selfSize.width - paddingHorz;
        }

        [sbs setArray:[self myGetAutoArrangeSubviews:sbs selfSize:selfSize.width - paddingHorz space:horzSpace]];

    }

    NSMutableIndexSet *arrangeIndexSet = [NSMutableIndexSet new];
    NSInteger arrangedIndex = 0;
    NSInteger i = 0;
    for (; i < sbs.count; i++)
    {
        UIView *sbv = sbs[i];

        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        CGFloat topSpace = sbvsc.topPosInner.absVal;
        CGFloat leadingSpace = sbvsc.leadingPosInner.absVal;
        CGFloat bottomSpace = sbvsc.bottomPosInner.absVal;
        CGFloat trailingSpace = sbvsc.trailingPosInner.absVal;
        CGRect rect = sbvmyFrame.frame;

        if (subviewSize != 0)
            rect.size.width = subviewSize;

        if (sbvsc.widthSizeInner.dimeNumVal != nil)
            rect.size.width = sbvsc.widthSizeInner.measure;

        if (sbvsc.heightSizeInner.dimeNumVal != nil)
            rect.size.height = sbvsc.heightSizeInner.measure;

        [self mySetSubviewRelativeDimeSize:sbvsc.widthSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

        [self mySetSubviewRelativeDimeSize:sbvsc.heightSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

        if (sbvsc.weight != 0)
        {
            //如果过了,则表示当前的剩余空间为0了,所以就按新的一行来算。。
            CGFloat floatWidth = selfSize.width - paddingHorz - rowMaxWidth;
            if (_myCGFloatLessOrEqual(floatWidth, 0))
            {
                floatWidth += rowMaxWidth;
                arrangedIndex = 0;
            }

            if (arrangedIndex != 0)
                floatWidth -= horzSpace;

            rect.size.width = (floatWidth + sbvsc.widthSizeInner.addVal) * sbvsc.weight - leadingSpace - trailingSpace;

        }

        rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:rect.size.width sbvSize:rect.size selfLayoutSize:selfSize];

        if (sbvsc.heightSizeInner.dimeRelaVal != nil && sbvsc.heightSizeInner.dimeRelaVal == sbvsc.widthSizeInner)
            rect.size.height = [sbvsc.heightSizeInner measureWith:rect.size.width ];

        //如果高度是浮动的则需要调整高度。
        if (sbvsc.wrapContentHeight && ![sbv isKindOfClass:[MyBaseLayout class]])
            rect.size.height = [self myHeightFromFlexedHeightView:sbv sbvsc:sbvsc inWidth:rect.size.width];

        rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];

        //计算xPos的值加上leadingSpace + rect.size.width + trailingSpace 的值要小于整体的宽度。
        CGFloat place = xPos + leadingSpace + rect.size.width + trailingSpace;
        if (arrangedIndex != 0)
            place += horzSpace;
        place += paddingTrailing;

        //sbv所占据的宽度要超过了视图的整体宽度,因此需要换行。但是如果arrangedIndex为0的话表示这个控件的整行的宽度和布局视图保持一致。
        if (place - selfSize.width > 0.0001)
        {
            xPos = paddingLeading;
            yPos += vertSpace;
            yPos += rowMaxHeight;

            [arrangeIndexSet addIndex:i - arrangedIndex];
            //计算每行的gravity情况。
            [self myCalcVertLayoutSinglelineAlignment:selfSize rowMaxHeight:rowMaxHeight rowMaxWidth:rowMaxWidth horzGravity:horzGravity vertAlignment:vertAlign sbs:sbs startIndex:i count:arrangedIndex vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];

            //计算单独的sbv的宽度是否大于整体的宽度。如果大于则缩小宽度。
            if (_myCGFloatGreat(leadingSpace + trailingSpace + rect.size.width, selfSize.width - paddingHorz))
            {

                rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:selfSize.width - paddingHorz - leadingSpace - trailingSpace sbvSize:rect.size selfLayoutSize:selfSize];

                if (sbvsc.wrapContentHeight && ![sbv isKindOfClass:[MyBaseLayout class]])
                {
                    rect.size.height = [self myHeightFromFlexedHeightView:sbv sbvsc:sbvsc inWidth:rect.size.width];
                    rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];
                }

            }

            rowMaxHeight = 0;
            rowMaxWidth = 0;
            arrangedIndex = 0;

        }

        if (arrangedIndex != 0)
            xPos += horzSpace;

        rect.origin.x = xPos + leadingSpace;
        rect.origin.y = yPos + topSpace;
        xPos += leadingSpace + rect.size.width + trailingSpace;

        if (_myCGFloatLess(rowMaxHeight, topSpace + bottomSpace + rect.size.height))
            rowMaxHeight = topSpace + bottomSpace + rect.size.height;

        if (_myCGFloatLess(rowMaxWidth, (xPos - paddingLeading)))
            rowMaxWidth = (xPos - paddingLeading);

        sbvmyFrame.frame = rect;

        arrangedIndex++;

    }

    //最后一行
    [arrangeIndexSet addIndex:i - arrangedIndex];

    [self myCalcVertLayoutSinglelineAlignment:selfSize rowMaxHeight:rowMaxHeight rowMaxWidth:rowMaxWidth horzGravity:horzGravity vertAlignment:vertAlign sbs:sbs startIndex:i count:arrangedIndex vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];

    if (lsc.wrapContentHeight)
        selfSize.height = yPos + paddingBottom + rowMaxHeight;
    else
    {
        CGFloat addYPos = 0;
        CGFloat between = 0;
        CGFloat fill = 0;

        if (vertGravity == MyGravity_Vert_Center)
        {
            addYPos = (selfSize.height - paddingBottom - rowMaxHeight - yPos) / 2;
        }
        else if (vertGravity == MyGravity_Vert_Bottom)
        {
            addYPos = selfSize.height - paddingBottom - rowMaxHeight - yPos;
        }
        else if (vertGravity == MyGravity_Vert_Fill)
        {
            if (arrangeIndexSet.count > 0)
                fill = (selfSize.height - paddingBottom - rowMaxHeight - yPos) / arrangeIndexSet.count;
        }
        else if (vertGravity == MyGravity_Vert_Between)
        {
            if (arrangeIndexSet.count > 1)
                between = (selfSize.height - paddingBottom - rowMaxHeight - yPos) / (arrangeIndexSet.count - 1);
        }

        if (addYPos != 0 || between != 0 || fill != 0)
        {
            int line = 0;
            NSUInteger lastIndex = 0;
            for (int i = 0; i < sbs.count; i++)
            {
                UIView *sbv = sbs[i];

                MyFrame *sbvmyFrame = sbv.myFrame;

                sbvmyFrame.top += addYPos;

                //找到行的最初索引。
                NSUInteger index = [arrangeIndexSet indexLessThanOrEqualToIndex:i];
                if (lastIndex != index)
                {
                    lastIndex = index;
                    line ++;
                }

                sbvmyFrame.height += fill;
                sbvmyFrame.top += fill * line;

                sbvmyFrame.top += between * line;

            }
        }

    }

    return selfSize;

}

-(CGSize)myLayoutSubviewsForVert:(CGSize)selfSize sbs:(NSMutableArray*)sbs isEstimate:(BOOL)isEstimate lsc:(MyFlowLayout*)lsc
{
    CGFloat paddingTop = lsc.myLayoutTopPadding;
    CGFloat paddingBottom = lsc.myLayoutBottomPadding;
    CGFloat paddingLeading = lsc.myLayoutLeadingPadding;
    CGFloat paddingTrailing = lsc.myLayoutTrailingPadding;
    CGFloat paddingHorz = paddingLeading + paddingTrailing;
    CGFloat paddingVert = paddingTop + paddingBottom;

    NSInteger arrangedCount = lsc.arrangedCount;
    CGFloat xPos = paddingLeading;
    CGFloat yPos = paddingTop;
    CGFloat rowMaxHeight = 0;  //某一行的最高值。
    CGFloat rowMaxWidth = 0;   //某一行的最宽值
    CGFloat maxWidth = paddingLeading;  //全部行的最宽值
    MyGravity vertGravity = lsc.gravity & MyGravity_Horz_Mask;
    MyGravity horzGravity = [self myConvertLeftRightGravityToLeadingTrailing:lsc.gravity & MyGravity_Vert_Mask];
    MyGravity vertAlign = lsc.arrangedGravity & MyGravity_Horz_Mask;

    CGFloat vertSpace = lsc.subviewVSpace;
    CGFloat horzSpace = lsc.subviewHSpace;

    //判断父滚动视图是否分页滚动
    BOOL isPagingScroll = (self.superview != nil &&
                           [self.superview isKindOfClass:[UIScrollView class]] &&
                           ((UIScrollView*)self.superview).isPagingEnabled);
    CGFloat pagingItemHeight = 0;
    CGFloat pagingItemWidth = 0;
    BOOL isVertPaging = NO;
    BOOL isHorzPaging = NO;
    if (lsc.pagedCount > 0 && self.superview != nil)
    {
        NSInteger rows = lsc.pagedCount / arrangedCount;  //每页的行数。

        //对于垂直流式布局来说,要求要有明确的宽度。因此如果我们启用了分页又设置了宽度包裹时则我们的分页是从左到右的排列。否则分页是从上到下的排列。
        if (lsc.wrapContentWidth)
        {
            isHorzPaging = YES;
            if (isPagingScroll)
                pagingItemWidth = (CGRectGetWidth(self.superview.bounds) - paddingHorz - (arrangedCount - 1) * horzSpace ) / arrangedCount;
            else
                pagingItemWidth = (CGRectGetWidth(self.superview.bounds) - paddingLeading - arrangedCount * horzSpace ) / arrangedCount;

            pagingItemHeight = (selfSize.height - paddingVert - (rows - 1) * vertSpace) / rows;
        }
        else
        {
            isVertPaging = YES;
            pagingItemWidth = (selfSize.width - paddingHorz - (arrangedCount - 1) * horzSpace) / arrangedCount;
            //分页滚动时和非分页滚动时的高度计算是不一样的。
            if (isPagingScroll)
                pagingItemHeight = (CGRectGetHeight(self.superview.bounds) - paddingVert - (rows - 1) * vertSpace) / rows;
            else
                pagingItemHeight = (CGRectGetHeight(self.superview.bounds) - paddingTop - rows * vertSpace) / rows;

        }

    }

    BOOL averageArrange = (horzGravity == MyGravity_Horz_Fill);

    NSInteger arrangedIndex = 0;
    NSInteger i = 0;
    CGFloat rowTotalWeight = 0;
    CGFloat rowTotalFixedWidth = 0;
    for (; i < sbs.count; i++)
    {
        UIView *sbv = sbs[i];

        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (arrangedIndex >= arrangedCount)
        {
            arrangedIndex = 0;

            if (rowTotalWeight != 0 && !averageArrange)
            {
                [self myCalcVertLayoutSinglelineWeight:selfSize totalFloatWidth:selfSize.width - paddingHorz - rowTotalFixedWidth totalWeight:rowTotalWeight sbs:sbs startIndex:i count:arrangedCount];
            }

            rowTotalWeight = 0;
            rowTotalFixedWidth = 0;

        }

        CGFloat leadingSpace = sbvsc.leadingPosInner.absVal;
        CGFloat trailingSpace = sbvsc.trailingPosInner.absVal;
        CGRect rect = sbvmyFrame.frame;

        if (sbvsc.weight != 0)
        {

            rowTotalWeight += sbvsc.weight;
        }
        else
        {
            if (pagingItemWidth != 0)
                rect.size.width = pagingItemWidth;

            if (sbvsc.widthSizeInner.dimeNumVal != nil && !averageArrange)
                rect.size.width = sbvsc.widthSizeInner.measure;

            [self mySetSubviewRelativeDimeSize:sbvsc.widthSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

            rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:rect.size.width sbvSize:rect.size selfLayoutSize:selfSize];

            rowTotalFixedWidth += rect.size.width;
        }

        rowTotalFixedWidth += leadingSpace + trailingSpace;

        if (arrangedIndex != (arrangedCount - 1))
            rowTotalFixedWidth += horzSpace;

        sbvmyFrame.frame = rect;

        arrangedIndex++;

    }

    //最后一行。
    if (rowTotalWeight != 0 && !averageArrange)
    {
        if (arrangedIndex < arrangedCount)
            rowTotalFixedWidth -= horzSpace;

        [self myCalcVertLayoutSinglelineWeight:selfSize totalFloatWidth:selfSize.width - paddingHorz - rowTotalFixedWidth totalWeight:rowTotalWeight sbs:sbs startIndex:i count:arrangedIndex];
    }

    CGFloat pageWidth  = 0; //页宽。
    CGFloat averageWidth = (selfSize.width - paddingHorz - (arrangedCount - 1) * horzSpace) / arrangedCount;
    arrangedIndex = 0;
    i = 0;
    for (; i < sbs.count; i++)
    {
        UIView *sbv = sbs[i];
        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        //新的一行
        if (arrangedIndex >=  arrangedCount)
        {
            arrangedIndex = 0;
            yPos += rowMaxHeight;
            yPos += vertSpace;

            //分别处理水平分页和垂直分页。
            if (isHorzPaging)
            {
                if (i % lsc.pagedCount == 0)
                {
                    pageWidth += CGRectGetWidth(self.superview.bounds);

                    if (!isPagingScroll)
                        pageWidth -= paddingLeading;

                    yPos = paddingTop;
                }

            }

            if (isVertPaging)
            {
                //如果是分页滚动则要多添加垂直间距。
                if (i % lsc.pagedCount == 0)
                {

                    if (isPagingScroll)
                    {
                        yPos -= vertSpace;
                        yPos += paddingVert;

                    }
                }
            }

            xPos = paddingLeading + pageWidth;

            //计算每行的gravity情况。
            [self myCalcVertLayoutSinglelineAlignment:selfSize rowMaxHeight:rowMaxHeight rowMaxWidth:rowMaxWidth horzGravity:horzGravity vertAlignment:vertAlign sbs:sbs startIndex:i count:arrangedCount vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];
            rowMaxHeight = 0;
            rowMaxWidth = 0;

        }

        CGFloat topSpace = sbvsc.topPosInner.absVal;
        CGFloat leadingSpace = sbvsc.leadingPosInner.absVal;
        CGFloat bottomSpace = sbvsc.bottomPosInner.absVal;
        CGFloat trailingSpace = sbvsc.trailingPosInner.absVal;
        CGRect rect = sbvmyFrame.frame;
        BOOL isFlexedHeight = sbvsc.wrapContentHeight && ![sbv isKindOfClass:[MyBaseLayout class]] && sbvsc.heightSizeInner.dimeRelaVal.view != self;

        if (pagingItemHeight != 0)
            rect.size.height = pagingItemHeight;

        if (sbvsc.heightSizeInner.dimeNumVal != nil)
            rect.size.height = sbvsc.heightSizeInner.measure;

        if (averageArrange)
        {
            rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:averageWidth - leadingSpace - trailingSpace sbvSize:rect.size selfLayoutSize:selfSize];
        }

        [self mySetSubviewRelativeDimeSize:sbvsc.heightSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

        //如果高度是浮动的则需要调整高度。
        if (isFlexedHeight)
            rect.size.height = [self myHeightFromFlexedHeightView:sbv sbvsc:sbvsc inWidth:rect.size.width];

        rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];

        rect.origin.x = xPos + leadingSpace;
        rect.origin.y = yPos + topSpace;
        xPos += leadingSpace + rect.size.width + trailingSpace;

        if (arrangedIndex != (arrangedCount - 1))
            xPos += horzSpace;

        if (_myCGFloatLess(rowMaxHeight, topSpace + bottomSpace + rect.size.height))
            rowMaxHeight = topSpace + bottomSpace + rect.size.height;

        if (_myCGFloatLess(rowMaxWidth, (xPos - paddingLeading)))
            rowMaxWidth = (xPos - paddingLeading);

        if (_myCGFloatLess(maxWidth, xPos))
            maxWidth = xPos;

        sbvmyFrame.frame = rect;

        arrangedIndex++;

    }

    //最后一行
    [self myCalcVertLayoutSinglelineAlignment:selfSize rowMaxHeight:rowMaxHeight rowMaxWidth:rowMaxWidth horzGravity:horzGravity vertAlignment:vertAlign sbs:sbs startIndex:i count:arrangedIndex vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];

    if (lsc.wrapContentHeight)
    {
        selfSize.height = yPos + paddingBottom + rowMaxHeight;

        //只有在父视图为滚动视图,且开启了分页滚动时才会扩充具有包裹设置的布局视图的宽度。
        if (isVertPaging && isPagingScroll)
        {
            //算出页数来。如果包裹计算出来的宽度小于指定页数的宽度,因为要分页滚动所以这里会扩充布局的宽度。
            NSInteger totalPages = floor((sbs.count + lsc.pagedCount - 1.0 ) / lsc.pagedCount);
            if (_myCGFloatLess(selfSize.height, totalPages * CGRectGetHeight(self.superview.bounds)))
                selfSize.height = totalPages * CGRectGetHeight(self.superview.bounds);
        }

    }
    else
    {
        CGFloat addYPos = 0;
        CGFloat between = 0;
        CGFloat fill = 0;
        int arranges = floor((sbs.count + arrangedCount - 1.0) / arrangedCount);

        if (vertGravity == MyGravity_Vert_Center)
        {
            addYPos = (selfSize.height - paddingBottom - rowMaxHeight - yPos) / 2;
        }
        else if (vertGravity == MyGravity_Vert_Bottom)
        {
            addYPos = selfSize.height - paddingBottom - rowMaxHeight - yPos;
        }
        else if (vertGravity == MyGravity_Vert_Fill)
        {
            if (arranges > 0)
                fill = (selfSize.height - paddingBottom - rowMaxHeight - yPos) / arranges;
        }
        else if (vertGravity == MyGravity_Vert_Between)
        {

            if (arranges > 1)
                between = (selfSize.height - paddingBottom - rowMaxHeight - yPos) / (arranges - 1);
        }

        if (addYPos != 0 || between != 0 || fill != 0)
        {
            for (int i = 0; i < sbs.count; i++)
            {
                UIView *sbv = sbs[i];

                MyFrame *sbvmyFrame = sbv.myFrame;

                int lines = i / arrangedCount;
                sbvmyFrame.height += fill;
                sbvmyFrame.top += fill * lines;

                sbvmyFrame.top += addYPos;

                sbvmyFrame.top += between * lines;

            }
        }

    }

    if (lsc.wrapContentWidth && !averageArrange)
    {
        selfSize.width = maxWidth + paddingTrailing;

        //只有在父视图为滚动视图,且开启了分页滚动时才会扩充具有包裹设置的布局视图的宽度。
        if (isHorzPaging && isPagingScroll)
        {
            //算出页数来。如果包裹计算出来的宽度小于指定页数的宽度,因为要分页滚动所以这里会扩充布局的宽度。
            NSInteger totalPages = floor((sbs.count + lsc.pagedCount - 1.0 ) / lsc.pagedCount);
            if (_myCGFloatLess(selfSize.width, totalPages * CGRectGetWidth(self.superview.bounds)))
                selfSize.width = totalPages * CGRectGetWidth(self.superview.bounds);
        }

    }

    return selfSize;
}

-(CGSize)myLayoutSubviewsForHorzContent:(CGSize)selfSize sbs:(NSMutableArray*)sbs isEstimate:(BOOL)isEstimate lsc:(MyFlowLayout*)lsc
{

    CGFloat paddingTop = lsc.myLayoutTopPadding;
    CGFloat paddingBottom = lsc.myLayoutBottomPadding;
    CGFloat paddingLeading = lsc.myLayoutLeadingPadding;
    CGFloat paddingTrailing = lsc.myLayoutTrailingPadding;
    CGFloat paddingVert = paddingTop + paddingBottom;

    CGFloat xPos = paddingLeading;
    CGFloat yPos = paddingTop;
    CGFloat colMaxWidth = 0;  //某一列的最宽值。
    CGFloat colMaxHeight = 0;   //某一列的最高值

    MyGravity vertGravity = lsc.gravity & MyGravity_Horz_Mask;
    MyGravity horzGravity = [self myConvertLeftRightGravityToLeadingTrailing:lsc.gravity & MyGravity_Vert_Mask];
    MyGravity horzAlign =  [self myConvertLeftRightGravityToLeadingTrailing:lsc.arrangedGravity & MyGravity_Vert_Mask];

    //支持浮动垂直间距。
    CGFloat vertSpace = lsc.subviewVSpace;
    CGFloat horzSpace = lsc.subviewHSpace;
    CGFloat subviewSize = ((MyFlowLayoutViewSizeClass*)self.myCurrentSizeClass).subviewSize;
    if (subviewSize != 0)
    {

        CGFloat minSpace = ((MyFlowLayoutViewSizeClass*)self.myCurrentSizeClass).minSpace;
        CGFloat maxSpace = ((MyFlowLayoutViewSizeClass*)self.myCurrentSizeClass).maxSpace;
        NSInteger rowCount =  floor((selfSize.height - paddingVert  + minSpace) / (subviewSize + minSpace));
        if (rowCount > 1)
        {
            vertSpace = (selfSize.height - paddingVert - subviewSize * rowCount)/(rowCount - 1);
            if (_myCGFloatGreat(vertSpace, maxSpace))
            {
                vertSpace = maxSpace;

                subviewSize =  (selfSize.height - paddingVert -  vertSpace * (rowCount - 1)) / rowCount;

            }
        }
    }

    if (lsc.autoArrange)
    {
        //计算出每个子视图的宽度。
        for (UIView* sbv in sbs)
        {
            MyFrame *sbvmyFrame = sbv.myFrame;
            UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

#ifdef DEBUG
            //约束异常:水平流式布局设置autoArrange为YES时,子视图不能将weight设置为非0.
            NSCAssert(sbvsc.weight == 0, @"Constraint exception!! horizontal flow layout:%@ 's subview:%@ can't set weight when the autoArrange set to YES",self, sbv);
#endif

            CGFloat topSpace = sbvsc.topPosInner.absVal;
            CGFloat bottomSpace = sbvsc.bottomPosInner.absVal;
            CGRect rect = sbvmyFrame.frame;

            if (sbvsc.widthSizeInner.dimeNumVal != nil)
                rect.size.width = sbvsc.widthSizeInner.measure;

            if (sbvsc.heightSizeInner.dimeNumVal != nil)
                rect.size.height = sbvsc.heightSizeInner.measure;

            [self mySetSubviewRelativeDimeSize:sbvsc.heightSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

            rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];

            [self mySetSubviewRelativeDimeSize:sbvsc.widthSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

            rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:rect.size.width sbvSize:rect.size selfLayoutSize:selfSize];

            //如果高度是浮动的则需要调整高度。
            if (sbvsc.wrapContentHeight && ![sbv isKindOfClass:[MyBaseLayout class]])
            {
                rect.size.height = [self myHeightFromFlexedHeightView:sbv sbvsc:sbvsc inWidth:rect.size.width];

                rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];
            }

            //暂时把宽度存放sbv.myFrame.trailing上。因为浮动布局来说这个属性无用。
            sbvmyFrame.trailing = topSpace + rect.size.height + bottomSpace;
            if (_myCGFloatGreat(sbvmyFrame.trailing, selfSize.height - paddingVert))
                sbvmyFrame.trailing = selfSize.height - paddingVert;
        }

        [sbs setArray:[self myGetAutoArrangeSubviews:sbs selfSize:selfSize.height - paddingVert space:vertSpace]];

    }

    NSMutableIndexSet *arrangeIndexSet = [NSMutableIndexSet new];
    NSInteger arrangedIndex = 0;
    NSInteger i = 0;
    for (; i < sbs.count; i++)
    {
        UIView *sbv = sbs[i];

        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        CGFloat topSpace = sbvsc.topPosInner.absVal;
        CGFloat leadingSpace = sbvsc.leadingPosInner.absVal;
        CGFloat bottomSpace = sbvsc.bottomPosInner.absVal;
        CGFloat trailingSpace = sbvsc.trailingPosInner.absVal;
        CGRect rect = sbvmyFrame.frame;

        if (sbvsc.widthSizeInner.dimeNumVal != nil)
            rect.size.width = sbvsc.widthSizeInner.measure;

        if (sbvsc.heightSizeInner.dimeNumVal != nil)
            rect.size.height = sbvsc.heightSizeInner.measure;

        [self mySetSubviewRelativeDimeSize:sbvsc.heightSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

        if (subviewSize != 0)
            rect.size.height = subviewSize;

        [self mySetSubviewRelativeDimeSize:sbvsc.widthSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

        if (sbvsc.weight != 0)
        {
            //如果过了,则表示当前的剩余空间为0了,所以就按新的一行来算。。
            CGFloat floatHeight = selfSize.height - paddingVert - colMaxHeight;
            if (_myCGFloatLessOrEqual(floatHeight, 0))
            {
                floatHeight += colMaxHeight;
                arrangedIndex = 0;
            }

            if (arrangedIndex != 0)
                floatHeight -= vertSpace;

            rect.size.height = (floatHeight + sbvsc.heightSizeInner.addVal) * sbvsc.weight - topSpace - bottomSpace;

        }

        rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];

        if (sbvsc.widthSizeInner.dimeRelaVal != nil && sbvsc.widthSizeInner.dimeRelaVal == sbvsc.heightSizeInner)
            rect.size.width = [sbvsc.widthSizeInner measureWith:rect.size.height ];

        rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:rect.size.width sbvSize:rect.size selfLayoutSize:selfSize];

        //如果高度是浮动的则需要调整高度。
        if (sbvsc.wrapContentHeight && ![sbv isKindOfClass:[MyBaseLayout class]])
        {
            rect.size.height = [self myHeightFromFlexedHeightView:sbv sbvsc:sbvsc inWidth:rect.size.width];

            rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];
        }

        //计算yPos的值加上topSpace + rect.size.height + bottomSpace的值要小于整体的高度。
        CGFloat place = yPos + topSpace + rect.size.height + bottomSpace;
        if (arrangedIndex != 0)
            place += vertSpace;
        place += paddingBottom;

        //sbv所占据的宽度要超过了视图的整体宽度,因此需要换行。但是如果arrangedIndex为0的话表示这个控件的整行的宽度和布局视图保持一致。
        if (place - selfSize.height > 0.0001)
        {
            yPos = paddingTop;
            xPos += horzSpace;
            xPos += colMaxWidth;

            //计算每行的gravity情况。
            [arrangeIndexSet addIndex:i - arrangedIndex];
            [self myCalcHorzLayoutSinglelineAlignment:selfSize colMaxWidth:colMaxWidth colMaxHeight:colMaxHeight vertGravity:vertGravity horzAlignment:horzAlign sbs:sbs startIndex:i count:arrangedIndex vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];

            //计算单独的sbv的高度是否大于整体的高度。如果大于则缩小高度。
            if (_myCGFloatGreat(topSpace + bottomSpace + rect.size.height, selfSize.height - paddingVert))
            {
                rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:selfSize.height - paddingVert - topSpace - bottomSpace sbvSize:rect.size selfLayoutSize:selfSize];
            }

            colMaxWidth = 0;
            colMaxHeight = 0;
            arrangedIndex = 0;

        }

        if (arrangedIndex != 0)
            yPos += vertSpace;

        rect.origin.x = xPos + leadingSpace;
        rect.origin.y = yPos + topSpace;
        yPos += topSpace + rect.size.height + bottomSpace;

        if (_myCGFloatLess(colMaxWidth, leadingSpace + trailingSpace + rect.size.width))
            colMaxWidth = leadingSpace + trailingSpace + rect.size.width;

        if (_myCGFloatLess(colMaxHeight, (yPos - paddingTop)))
            colMaxHeight = (yPos - paddingTop);

        sbvmyFrame.frame = rect;

        arrangedIndex++;

    }

    //最后一行
    [arrangeIndexSet addIndex:i - arrangedIndex];
    [self myCalcHorzLayoutSinglelineAlignment:selfSize colMaxWidth:colMaxWidth colMaxHeight:colMaxHeight vertGravity:vertGravity horzAlignment:horzAlign sbs:sbs startIndex:i count:arrangedIndex vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];

    if (lsc.wrapContentWidth)
        selfSize.width = xPos + paddingTrailing + colMaxWidth;
    else
    {
        CGFloat addXPos = 0;
        CGFloat fill = 0;
        CGFloat between = 0;

        if (horzGravity == MyGravity_Horz_Center)
        {
            addXPos = (selfSize.width - paddingTrailing - colMaxWidth - xPos) / 2;
        }
        else if (horzGravity == MyGravity_Horz_Trailing)
        {
            addXPos = selfSize.width - paddingTrailing - colMaxWidth - xPos;
        }
        else if (horzGravity == MyGravity_Horz_Fill)
        {
            if (arrangeIndexSet.count > 0)
                fill = (selfSize.width - paddingTrailing - colMaxWidth - xPos) / arrangeIndexSet.count;
        }
        else if (horzGravity == MyGravity_Horz_Between)
        {
            if (arrangeIndexSet.count > 1)
                between = (selfSize.width - paddingTrailing - colMaxWidth - xPos) / (arrangeIndexSet.count - 1);
        }

        if (addXPos != 0 || between != 0 || fill != 0)
        {
            int line = 0;
            NSUInteger lastIndex = 0;
            for (int i = 0; i < sbs.count; i++)
            {
                UIView *sbv = sbs[i];
                MyFrame *sbvmyFrame = sbv.myFrame;

                sbvmyFrame.leading += addXPos;

                //找到行的最初索引。
                NSUInteger index = [arrangeIndexSet indexLessThanOrEqualToIndex:i];
                if (lastIndex != index)
                {
                    lastIndex = index;
                    line ++;
                }

                sbvmyFrame.width += fill;
                sbvmyFrame.leading += fill * line;

                sbvmyFrame.leading += between * line;

            }
        }

    }

    return selfSize;
}

-(CGSize)myLayoutSubviewsForHorz:(CGSize)selfSize sbs:(NSMutableArray*)sbs isEstimate:(BOOL)isEstimate lsc:(MyFlowLayout*)lsc
{
    CGFloat paddingTop = lsc.myLayoutTopPadding;
    CGFloat paddingBottom = lsc.myLayoutBottomPadding;
    CGFloat paddingLeading = lsc.myLayoutLeadingPadding;
    CGFloat paddingTrailing = lsc.myLayoutTrailingPadding;
    CGFloat paddingHorz = paddingLeading + paddingTrailing;
    CGFloat paddingVert = paddingTop + paddingBottom;

    NSInteger arrangedCount = lsc.arrangedCount;
    CGFloat xPos = paddingLeading;
    CGFloat yPos = paddingTop;
    CGFloat colMaxWidth = 0;  //每列的最大宽度
    CGFloat colMaxHeight = 0; //每列的最大高度
    CGFloat maxHeight = paddingTop;

    MyGravity vertGravity = lsc.gravity & MyGravity_Horz_Mask;
    MyGravity horzGravity = [self myConvertLeftRightGravityToLeadingTrailing:lsc.gravity & MyGravity_Vert_Mask];
    MyGravity horzAlign =  [self myConvertLeftRightGravityToLeadingTrailing:lsc.arrangedGravity & MyGravity_Vert_Mask];

    CGFloat vertSpace = lsc.subviewVSpace;
    CGFloat horzSpace = lsc.subviewHSpace;

    //父滚动视图是否分页滚动。
    BOOL isPagingScroll = (self.superview != nil &&
                           [self.superview isKindOfClass:[UIScrollView class]] &&
                           ((UIScrollView*)self.superview).isPagingEnabled);

    CGFloat pagingItemHeight = 0;
    CGFloat pagingItemWidth = 0;
    BOOL isVertPaging = NO;
    BOOL isHorzPaging = NO;
    if (lsc.pagedCount > 0 && self.superview != nil)
    {
        NSInteger cols = lsc.pagedCount / arrangedCount;  //每页的列数。

        //对于水平流式布局来说,要求要有明确的高度。因此如果我们启用了分页又设置了高度包裹时则我们的分页是从上到下的排列。否则分页是从左到右的排列。
        if (lsc.wrapContentHeight)
        {
            isVertPaging = YES;
            if (isPagingScroll)
                pagingItemHeight = (CGRectGetHeight(self.superview.bounds) - paddingVert - (arrangedCount - 1) * vertSpace ) / arrangedCount;
            else
                pagingItemHeight = (CGRectGetHeight(self.superview.bounds) - paddingTop - arrangedCount * vertSpace ) / arrangedCount;

            pagingItemWidth = (selfSize.width - paddingHorz - (cols - 1) * horzSpace) / cols;
        }
        else
        {
            isHorzPaging = YES;
            pagingItemHeight = (selfSize.height - paddingVert - (arrangedCount - 1) * vertSpace) / arrangedCount;
            //分页滚动时和非分页滚动时的宽度计算是不一样的。
            if (isPagingScroll)
                pagingItemWidth = (CGRectGetWidth(self.superview.bounds) - paddingHorz - (cols - 1) * horzSpace) / cols;
            else
                pagingItemWidth = (CGRectGetWidth(self.superview.bounds) - paddingLeading - cols * horzSpace) / cols;

        }

    }

    BOOL averageArrange = (vertGravity == MyGravity_Vert_Fill);

    NSInteger arrangedIndex = 0;
    NSInteger i = 0;
    CGFloat rowTotalWeight = 0;
    CGFloat rowTotalFixedHeight = 0;
    for (; i < sbs.count; i++)
    {
        UIView *sbv = sbs[i];
        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (arrangedIndex >= arrangedCount)
        {
            arrangedIndex = 0;

            if (rowTotalWeight != 0 && !averageArrange)
            {
                [self myCalcHorzLayoutSinglelineWeight:selfSize totalFloatHeight:selfSize.height - paddingVert - rowTotalFixedHeight totalWeight:rowTotalWeight sbs:sbs startIndex:i count:arrangedCount];
            }

            rowTotalWeight = 0;
            rowTotalFixedHeight = 0;

        }

        CGFloat topSpace = sbvsc.topPosInner.absVal;
        CGFloat bottomSpace = sbvsc.bottomPosInner.absVal;
        CGRect rect = sbvmyFrame.frame;

        if (pagingItemWidth != 0)
            rect.size.width = pagingItemWidth;

        if (sbvsc.widthSizeInner.dimeNumVal != nil)
            rect.size.width = sbvsc.widthSizeInner.measure;

        //当子视图的尺寸是相对依赖于其他尺寸的值。
        [self mySetSubviewRelativeDimeSize:sbvsc.widthSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

        rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:rect.size.width sbvSize:rect.size selfLayoutSize:selfSize];

        if (sbvsc.weight != 0)
        {

            rowTotalWeight += sbvsc.weight;
        }
        else
        {

            BOOL isFlexedHeight = sbvsc.wrapContentHeight && ![sbv isKindOfClass:[MyBaseLayout class]] && sbvsc.heightSizeInner.dimeRelaVal.view != self;

            if (pagingItemHeight != 0)
                rect.size.height = pagingItemHeight;

            if (sbvsc.heightSizeInner.dimeNumVal != nil && !averageArrange)
                rect.size.height = sbvsc.heightSizeInner.measure;

            //当子视图的尺寸是相对依赖于其他尺寸的值。
            [self mySetSubviewRelativeDimeSize:sbvsc.heightSizeInner selfSize:selfSize lsc:lsc pRect:&rect];

            //如果高度是浮动的则需要调整高度。
            if (isFlexedHeight)
                rect.size.height = [self myHeightFromFlexedHeightView:sbv sbvsc:sbvsc inWidth:rect.size.width];

            rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:rect.size.height sbvSize:rect.size selfLayoutSize:selfSize];

            if (sbvsc.widthSizeInner.dimeRelaVal != nil && sbvsc.widthSizeInner.dimeRelaVal == sbvsc.heightSizeInner)
                rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:[sbvsc.widthSizeInner measureWith: rect.size.height ] sbvSize:rect.size selfLayoutSize:selfSize];

            rowTotalFixedHeight += rect.size.height;
        }

        rowTotalFixedHeight += topSpace + bottomSpace;

        if (arrangedIndex != (arrangedCount - 1))
            rowTotalFixedHeight += vertSpace;

        sbvmyFrame.frame = rect;

        arrangedIndex++;

    }

    //最后一行。
    if (rowTotalWeight != 0 && !averageArrange)
    {
        if (arrangedIndex < arrangedCount)
            rowTotalFixedHeight -= vertSpace;

        [self myCalcHorzLayoutSinglelineWeight:selfSize totalFloatHeight:selfSize.height - paddingVert - rowTotalFixedHeight totalWeight:rowTotalWeight sbs:sbs startIndex:i count:arrangedIndex];
    }

    CGFloat pageHeight = 0; //页高
    CGFloat averageHeight = (selfSize.height - paddingVert - (arrangedCount - 1) * vertSpace) / arrangedCount;
    arrangedIndex = 0;
    i = 0;
    for (; i < sbs.count; i++)
    {
        UIView *sbv = sbs[i];
        MyFrame *sbvmyFrame = sbv.myFrame;
        UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];

        if (arrangedIndex >=  arrangedCount)
        {
            arrangedIndex = 0;
            xPos += colMaxWidth;
            xPos += horzSpace;

            //分别处理水平分页和垂直分页。
            if (isVertPaging)
            {
                if (i % lsc.pagedCount == 0)
                {
                    pageHeight += CGRectGetHeight(self.superview.bounds);

                    if (!isPagingScroll)
                        pageHeight -= paddingTop;

                    xPos = paddingLeading;
                }

            }

            if (isHorzPaging)
            {
                //如果是分页滚动则要多添加垂直间距。
                if (i % lsc.pagedCount == 0)
                {

                    if (isPagingScroll)
                    {
                        xPos -= horzSpace;
                        xPos += paddingTrailing;
                        xPos += paddingLeading;
                    }
                }
            }

            yPos = paddingTop + pageHeight;

            //计算每行的gravity情况。
            [self myCalcHorzLayoutSinglelineAlignment:selfSize colMaxWidth:colMaxWidth colMaxHeight:colMaxHeight vertGravity:vertGravity horzAlignment:horzAlign sbs:sbs startIndex:i count:arrangedCount vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];

            colMaxWidth = 0;
            colMaxHeight = 0;
        }

        CGFloat topSpace = sbvsc.topPosInner.absVal;
        CGFloat leadingSpace = sbvsc.leadingPosInner.absVal;
        CGFloat bottomSpace = sbvsc.bottomPosInner.absVal;
        CGFloat trailingSpace = sbvsc.trailingPosInner.absVal;
        CGRect rect = sbvmyFrame.frame;

        if (averageArrange)
        {

            rect.size.height = [self myValidMeasure:sbvsc.heightSizeInner sbv:sbv calcSize:averageHeight - topSpace - bottomSpace sbvSize:rect.size selfLayoutSize:selfSize];

            if (sbvsc.widthSizeInner.dimeRelaVal != nil && sbvsc.widthSizeInner.dimeRelaVal == sbvsc.heightSizeInner)
                rect.size.width = [self myValidMeasure:sbvsc.widthSizeInner sbv:sbv calcSize:[sbvsc.widthSizeInner measureWith: rect.size.height ] sbvSize:rect.size selfLayoutSize:selfSize];
        }

        rect.origin.y = yPos + topSpace;
        rect.origin.x = xPos + leadingSpace;
        yPos += topSpace + rect.size.height + bottomSpace;

        if (arrangedIndex != (arrangedCount - 1))
            yPos += vertSpace;

        if (_myCGFloatLess(colMaxWidth, leadingSpace + trailingSpace + rect.size.width))
            colMaxWidth = leadingSpace + trailingSpace + rect.size.width;

        if (_myCGFloatLess(colMaxHeight, (yPos - paddingTop)))
            colMaxHeight = yPos - paddingTop;

        if (_myCGFloatLess(maxHeight, yPos))
            maxHeight = yPos;

        sbvmyFrame.frame = rect;

        arrangedIndex++;

    }

    //最后一列
    [self myCalcHorzLayoutSinglelineAlignment:selfSize colMaxWidth:colMaxWidth colMaxHeight:colMaxHeight vertGravity:vertGravity horzAlignment:horzAlign sbs:sbs startIndex:i count:arrangedIndex vertSpace:vertSpace horzSpace:horzSpace isEstimate:isEstimate lsc:lsc];

    if (lsc.wrapContentHeight && !averageArrange)
    {
        selfSize.height = maxHeight + paddingBottom;

        //只有在父视图为滚动视图,且开启了分页滚动时才会扩充具有包裹设置的布局视图的宽度。
        if (isVertPaging && isPagingScroll)
        {
            //算出页数来。如果包裹计算出来的宽度小于指定页数的宽度,因为要分页滚动所以这里会扩充布局的宽度。
            NSInteger totalPages = floor((sbs.count + lsc.pagedCount - 1.0 ) / lsc.pagedCount);
            if (_myCGFloatLess(selfSize.height, totalPages * CGRectGetHeight(self.superview.bounds)))
                selfSize.height = totalPages * CGRectGetHeight(self.superview.bounds);
        }

    }

    if (lsc.wrapContentWidth)
    {
        selfSize.width = xPos + paddingTrailing + colMaxWidth;

        //只有在父视图为滚动视图,且开启了分页滚动时才会扩充具有包裹设置的布局视图的宽度。
        if (isHorzPaging && isPagingScroll)
        {
            //算出页数来。如果包裹计算出来的宽度小于指定页数的宽度,因为要分页滚动所以这里会扩充布局的宽度。
            NSInteger totalPages = floor((sbs.count + lsc.pagedCount - 1.0 ) / lsc.pagedCount);
            if (_myCGFloatLess(selfSize.width, totalPages * CGRectGetWidth(self.superview.bounds)))
                selfSize.width = totalPages * CGRectGetWidth(self.superview.bounds);
        }

    }
    else
    {

        CGFloat addXPos = 0;
        CGFloat between = 0;
        CGFloat fill = 0;
        int arranges = floor((sbs.count + arrangedCount - 1.0) / arrangedCount);

        if (horzGravity == MyGravity_Horz_Center)
        {
            addXPos = (selfSize.width - paddingTrailing - colMaxWidth - xPos) / 2;
        }
        else if (horzGravity == MyGravity_Horz_Trailing)
        {
            addXPos = selfSize.width - paddingTrailing - colMaxWidth - xPos;
        }
        else if (horzGravity == MyGravity_Horz_Fill)
        {
            if (arranges > 0)
                fill = (selfSize.width - paddingTrailing - colMaxWidth - xPos) / arranges;
        }
        else if (horzGravity == MyGravity_Horz_Between)
        {
            if (arranges > 1)
                between = (selfSize.width - paddingLeading - colMaxWidth - xPos) / (arranges - 1);
        }

        if (addXPos != 0 || between != 0 || fill != 0)
        {
            for (int i = 0; i < sbs.count; i++)
            {
                UIView *sbv = sbs[i];

                MyFrame *sbvmyFrame = sbv.myFrame;

                int lines = i / arrangedCount;
                sbvmyFrame.width += fill;
                sbvmyFrame.leading += fill * lines;

                sbvmyFrame.leading += addXPos;

                sbvmyFrame.leading += between * lines;

            }
        }
    }

    return selfSize;

}

@end


text:
// This file is automatically generated.

package adila.db;

/*
 * Samsung Galaxy Ace 3
 *
 * DEVICE: loganrelte
 * MODEL: GT-S7275R
 */
final class loganrelte_gt2ds7275r {
    public static final String DATA = "Samsung|Galaxy Ace 3|";
}


text:
namespace ork {
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

class Mutex
{
public:
	//////////////////////////////////
	Mutex();
	~Mutex();
	//////////////////////////////////
	void Lock();	// recursively lock
	void Unlock();	// recursively unlock
	//////////////////////////////////
	bool IsLocked() const { return mbLocked; }
	//////////////////////////////////
private:
	pthread_mutex_t		mMutex;
	pthread_mutexattr_t	mMutexAttr;
	bool				mbLocked;

};

///////////////////////////////////////////////////////////////////////////////

//! A locked resource is just a mutex wrapped resource which must be locked to access
//!  dont forget to unlock it when done.... (TODO: RAII based auto-unlock)

template <typename T> struct LockedResource
{
    typedef std::function<void(T& ref)> ref_lambda_t;
    typedef std::function<void(const T& ref)> const_ref_lambda_t;
	//////////////////////////////////
	LockedResource()
	{
	}
	//////////////////////////////////
	~LockedResource()
	{
		//MyAssert( false == mResourceMutex.IsLocked() );
	}
	//////////////////////////////////
	const T& LockForRead() const
	{	mResourceMutex.Lock();
		return mResource;
	}
	//////////////////////////////////
	T& LockForWrite()
	{	mResourceMutex.Lock();
		return mResource;
	}
	//////////////////////////////////
	void Unlock() const
	{	mResourceMutex.Unlock();
	}
	//////////////////////////////////
   void AtomicCopy( T& out_copy ) const // perhaps we can try out c++11 move semantics with this
    {
        mResourceMutex.Lock();
        out_copy = mResource;
        mResourceMutex.Unlock();
    }
	T AtomicCopy() const
	{
		mResourceMutex.Lock();
		T rval = mResource;
		mResourceMutex.Unlock();
		return rval;
	}
	//////////////////////////////////
	void AtomicOp( const ref_lambda_t& op )
	{
		mResourceMutex.Lock();
		op(mResource);
		mResourceMutex.Unlock();
	}
	//////////////////////////////////
	void AtomicOp( const const_ref_lambda_t& op ) const
	{
		mResourceMutex.Lock();
		op(mResource);
		mResourceMutex.Unlock();
	}
	//////////////////////////////////
private:
	T										mResource;
	mutable Mutex							mResourceMutex;
};

///////////////////////////////////////////////////////////////////////////////
} //namespace ork {


text:
import thinky from '../thinky';
const type = thinky.type;

const Todo = thinky.createModel('todo', {
  text: type.string(),
  completed: type.boolean(),
  user_id: type.string().allowNull(false)
});

Todo.relations = () => {
  Todo.belongsTo(thinky.models.user,'user','user_id','id');
}

Todo.ensureIndex("completed");

export default Todo;


text:
[![NPM version](https://img.shields.io/npm/v/express-tongue.svg?style=flat)](https://www.npmjs.com/package/express-tongue)
[![NPM Downloads](https://img.shields.io/npm/dm/express-tongue.svg)](https://www.npmjs.com/package/express-tongue)
[![Build Status](https://travis-ci.org/clcastro87/express-tongue.svg?branch=master)](https://travis-ci.org/clcastro87/express-tongue)
[![Issues](https://img.shields.io/github/issues/clcastro87/express-tongue.svg)](https://travis-ci.org/clcastro87/express-tongue)
[![GitHub forks](https://img.shields.io/github/forks/clcastro87/express-tongue.svg)](https://github.com/clcastro87/express-tongue/network)
[![GitHub stars](https://img.shields.io/github/stars/clcastro87/express-tongue.svg)](https://github.com/clcastro87/express-tongue/stargazers)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/clcastro87/express-tongue/master/LICENSE)

**Express middleware to handle sites in multiple languages.**

The following localization setup are supported:

  - authenticated user with language attribute
    ```js
    Ex: req.user.language
    ```
  - querystring
    ```
    Ex: ?hl=en
    ```
  - cookie
  - User-Agent
  - default language

## Install

```bash
$ npm install express-tongue
```

## API

```js
var app = express();
var i18n = require('express-tongue');
app.use(i18n.localize({
    endpointEnabled: true,
    path: __dirname + '/i18n',
    queryStringEnabled: true
}));
```

### localize([options])

Returns the localization middleware using the given `options`. This middleware injects
the variable i18n inside res.locals, for usage inside template engines. Also is you are
planning to use localization on client side; for example in SPA, then you have
several endpoints which helps you to develop a fully localized page.

#### Options

`localize()` accepts these properties in the options object.

##### defaultLang

Default language abbreviation. Defaults to `en`.

##### path

Directory where localization files are located. Defaults to `WORKING_DIR/i18n`.

##### languages

Replace available languages for those specified in array. This is useful when you want
to deactivate some language.

##### endpointEnabled

Enables API endpoint for usage in client apps. Defaults to `false`

##### endpointPath

Route in which endpoint will be mounted. Defaults to `/i18n`

##### queryStringEnabled

Allows language replacement by setting key in querystring.

##### queryStringKey

Setup key used in querystring to define current language. Defaults to `hl`.

#### langCookie

Cookie name for storing current locale.

## Examples

### express/connect

When using this module with express or connect, simply `app.use` the module as
high as you like. Requests that pass through the middleware will inject `i18n` property
to res.locals

```js
var i18n = require('compression')
var express = require('express')

var app = express();
var i18n = require('express-tongue');
app.use(i18n.localize({
    endpointEnabled: true,
    path: __dirname + '/i18n',
    queryStringEnabled: true
}));

app.use('/locals', function(req, res) {
    res.json(res.locals.i18n);
});
```

## License

[MIT](LICENSE)


text:
		<title>Cucumber test page 2</title>

Cucumber test page 2

			This is a test page with a few links to test that the Cucumber framework is nicely controlling Selenium.

Navigation

Test page 1

Test page 2

Test page 3


text:
import { __core_private__ as r } from '@angular/core';
export var RenderDebugInfo = r.RenderDebugInfo;
export var wtfInit = r.wtfInit;
export var ReflectionCapabilities = r.ReflectionCapabilities;
export var VIEW_ENCAPSULATION_VALUES = r.VIEW_ENCAPSULATION_VALUES;
export var DebugDomRootRenderer = r.DebugDomRootRenderer;
/**
 * @experimental bogus marker to pass the ts-api-guardian's check - this api should be public so
 * this line will go away when that happens
 */
export var SecurityContext = r.SecurityContext;
export var SanitizationService = r.SanitizationService;
export var reflector = r.reflector;
export var NoOpAnimationPlayer = r.NoOpAnimationPlayer;
export var AnimationPlayer = r.AnimationPlayer;
export var NoOpAnimationDriver = r.NoOpAnimationDriver;
export var AnimationDriver = r.AnimationDriver;
export var AnimationSequencePlayer = r.AnimationSequencePlayer;
export var AnimationGroupPlayer = r.AnimationGroupPlayer;
export var AnimationKeyframe = r.AnimationKeyframe;
export var AnimationStyles = r.AnimationStyles;
export var prepareFinalAnimationStyles = r.prepareFinalAnimationStyles;
export var balanceAnimationKeyframes = r.balanceAnimationKeyframes;
export var flattenStyles = r.flattenStyles;
export var clearStyles = r.clearStyles;
export var collectAndResolveStyles = r.collectAndResolveStyles;
//# sourceMappingURL=core_private.js.map


text:
'use strict';

// MODULES //

var exec = require( 'child_process' ).execSync; // eslint-disable-line node/no-sync
var logger = require( 'debug' );
var trim = require( '@stdlib/string/trim' );
var extname = require( '@stdlib/utils/extname' );

// VARIABLES //

var debug = logger( 'remark-img-equations-src-urls:git' );

// Regular expression to extract a repository slug:
var RE = /(?:.+github\.com)(?:\/|:)(.+)/;

// MAIN //

/**
* Returns git repository info.
*
* @private
* @returns {Object} repository info
*/
function git() {
	var branch;
	var origin;
	var slug;
	var opts;
	var dir;
	var cmd;
	var out;
	var ext;

	// Get the local git repository path:
	dir = exec( 'git rev-parse --show-toplevel' );
	dir = trim( dir.toString() );
	dir = dir.match( /(.+)/ )[ 1 ];
	debug( 'Local repository directory: %s', dir );

	opts = {
		'cwd': dir
	};

	// Get the current branch:
	cmd = 'git rev-parse --abbrev-ref HEAD';
	out = exec( cmd, opts );
	branch = trim( out.toString() );
	debug( 'Branch: %s', branch );

	// Get the remote origin:
	cmd = 'git config --get remote.origin.url';
	out = exec( cmd, opts );
	origin = trim( out.toString() );
	ext = extname( origin ); // e.g., https://github.com/stdlib-js/stdlib.git
	if ( ext ) {
		origin = origin.slice( 0, origin.length-ext.length ); // e.g., https://github.com/stdlib-js/stdlib
	}
	debug( 'Remote origin: %s', origin );

	// Extract the repository slug:
	slug = origin.match( RE )[ 1 ];
	debug( 'Repository slug: %s', slug );

	out = {
		'dir': dir,
		'slug': slug,
		'origin': origin,
		'branch': branch
	};
	return out;
}

// EXPORTS //

module.exports = git;


text:
package terraform

import (
	"fmt"
	"log"
)

// ResourceRefreshPlannableTransformer is a GraphTransformer that replaces any
// nodes that don't have state yet exist in config with
// NodePlannableResourceInstance.
//
// This transformer is used when expanding count on managed resource nodes
// during the refresh phase to ensure that data sources that have
// interpolations that depend on resources existing in the graph can be walked
// properly.
type ResourceRefreshPlannableTransformer struct {
	// The full global state.
	State *State
}

// Transform implements GraphTransformer for
// ResourceRefreshPlannableTransformer.
func (t *ResourceRefreshPlannableTransformer) Transform(g *Graph) error {
nextVertex:
	for _, v := range g.Vertices() {
		addr := v.(*NodeRefreshableManagedResourceInstance).Addr

		// Find the state for this address, if there is one
		filter := &StateFilter{State: t.State}
		results, err := filter.Filter(addr.String())
		if err != nil {
			return err
		}

		// Check to see if we have a state for this resource. If we do, skip this
		// node.
		for _, result := range results {
			if _, ok := result.Value.(*ResourceState); ok {
				continue nextVertex
			}
		}
		// If we don't, convert this resource to a NodePlannableResourceInstance node
		// with all of the data we need to make it happen.
		log.Printf("[TRACE] No state for %s, converting to NodePlannableResourceInstance", addr.String())
		new := &NodePlannableResourceInstance{
			NodeAbstractResource: v.(*NodeRefreshableManagedResourceInstance).NodeAbstractResource,
		}
		// Replace the node in the graph
		if !g.Replace(v, new) {
			return fmt.Errorf("ResourceRefreshPlannableTransformer: Could not replace node %#v with %#v", v, new)
		}
	}

	return nil
}


text:
package firecampdockerlog

import (
	"encoding/json"
	"errors"
	"net/http"

	"github.com/docker/docker/daemon/logger"
	"github.com/docker/go-plugins-helpers/sdk"
)

type StartLoggingRequest struct {
	File string
	Info logger.Info
}

type StopLoggingRequest struct {
	File string
}

type CapabilitiesResponse struct {
	Err string
	Cap logger.Capability
}

type ReadLogsRequest struct {
	Info   logger.Info
	Config logger.ReadConfig
}

const START_LOGGING_REQUEST string = "/LogDriver.StartLogging"
const STOP_LOGGING_REQUEST string = "/LogDriver.StopLogging"
const LOG_CAPABILITIES_REQUEST string = "/LogDriver.Capabilities"

func NewHandler(h *sdk.Handler, region string, cluster string) {
	d := newDriver(region, cluster)
	h.HandleFunc(START_LOGGING_REQUEST, startLoggingHandleFunc(d))
	h.HandleFunc(STOP_LOGGING_REQUEST, stopLoggingHandleFunc(d))
	h.HandleFunc(LOG_CAPABILITIES_REQUEST, capabilityHandleFunc(d))
}

type response struct {
	Err string
}

func respond(err error, w http.ResponseWriter) {
	var res response
	if err != nil {
		res.Err = err.Error()
	}
	json.NewEncoder(w).Encode(&res)
}

func startLoggingHandleFunc(d LogDriver) func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		var req StartLoggingRequest
		if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
			return
		}

		if req.Info.ContainerID == "" {
			respond(errors.New("must provide container id in log context"), w)
			return
		}

		err := d.StartLogging(req.File, req.Info)
		respond(err, w)
	}
}

func stopLoggingHandleFunc(d LogDriver) func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		var req StopLoggingRequest
		if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
			http.Error(w, err.Error(), http.StatusBadRequest)
			return
		}

		err := d.StopLogging(req.File)
		respond(err, w)
	}
}

func capabilityHandleFunc(d LogDriver) func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		json.NewEncoder(w).Encode(
			&CapabilitiesResponse{
				Cap: d.GetCapability(),
			},
		)
	}
}


text:
namespace blink {

ThreadScheduler* ThreadScheduler::Current() {
  return Thread::Current()->Scheduler();
}

}  // namespace blink