text:
using System.Data.Common;
using System.Runtime.InteropServices;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace System.Data.SqlTypes
{
    /// <summary>
    /// Represents a 16-bit signed integer to be stored in or retrieved from a database.
    /// </summary>
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    [XmlSchemaProvider("GetXsdType")]
    public struct SqlInt16 : INullable, IComparable, IXmlSerializable
    {
        private bool _fNotNull; // false if null
        private short _value;

        private static readonly int s_MASKI2 = ~0x00007fff;

        // constructor
        // construct a Null
        private SqlInt16(bool fNull)
        {
            _fNotNull = false;
            _value = 0;
        }

        public SqlInt16(short value)
        {
            _value = value;
            _fNotNull = true;
        }

        // INullable
        public bool IsNull
        {
            get { return !_fNotNull; }
        }

        // property: Value
        public short Value
        {
            get
            {
                if (_fNotNull)
                    return _value;
                else
                    throw new SqlNullValueException();
            }
        }

        // Implicit conversion from short to SqlInt16
        public static implicit operator SqlInt16(short x)
        {
            return new SqlInt16(x);
        }

        // Explicit conversion from SqlInt16 to short. Throw exception if x is Null.
        public static explicit operator short (SqlInt16 x)
        {
            return x.Value;
        }

        public override string ToString()
        {
            return IsNull ? SQLResource.s_nullString : _value.ToString((IFormatProvider)null);
        }

        public static SqlInt16 Parse(string s)
        {
            if (s == SQLResource.s_nullString)
                return SqlInt16.Null;
            else
                return new SqlInt16(short.Parse(s, null));
        }

        // Unary operators
        public static SqlInt16 operator -(SqlInt16 x)
        {
            return x.IsNull ? Null : new SqlInt16((short)-x._value);
        }

        public static SqlInt16 operator ~(SqlInt16 x)
        {
            return x.IsNull ? Null : new SqlInt16((short)~x._value);
        }

        // Binary operators

        // Arithmetic operators
        public static SqlInt16 operator +(SqlInt16 x, SqlInt16 y)
        {
            if (x.IsNull || y.IsNull)
                return Null;

            int iResult = x._value + y._value;
            if ((((iResult >> 15) ^ (iResult >> 16)) & 1) != 0) // Bit 15 != bit 16
                throw new OverflowException(SQLResource.s_arithOverflowMessage);
            else
                return new SqlInt16((short)iResult);
        }

        public static SqlInt16 operator -(SqlInt16 x, SqlInt16 y)
        {
            if (x.IsNull || y.IsNull)
                return Null;

            int iResult = x._value - y._value;
            if ((((iResult >> 15) ^ (iResult >> 16)) & 1) != 0) // Bit 15 != bit 16
                throw new OverflowException(SQLResource.s_arithOverflowMessage);
            else
                return new SqlInt16((short)iResult);
        }

        public static SqlInt16 operator *(SqlInt16 x, SqlInt16 y)
        {
            if (x.IsNull || y.IsNull)
                return Null;

            int iResult = x._value * y._value;
            int iTemp = iResult & s_MASKI2;
            if (iTemp != 0 && iTemp != s_MASKI2)
                throw new OverflowException(SQLResource.s_arithOverflowMessage);
            else
                return new SqlInt16((short)iResult);
        }

        public static SqlInt16 operator /(SqlInt16 x, SqlInt16 y)
        {
            if (x.IsNull || y.IsNull)
                return Null;

            if (y._value != 0)
            {
                if ((x._value == short.MinValue) && (y._value == -1))
                    throw new OverflowException(SQLResource.s_arithOverflowMessage);

                return new SqlInt16((short)(x._value / y._value));
            }
            else
                throw new DivideByZeroException(SQLResource.s_divideByZeroMessage);
        }

        public static SqlInt16 operator %(SqlInt16 x, SqlInt16 y)
        {
            if (x.IsNull || y.IsNull)
                return Null;

            if (y._value != 0)
            {
                if ((x._value == short.MinValue) && (y._value == -1))
                    throw new OverflowException(SQLResource.s_arithOverflowMessage);

                return new SqlInt16((short)(x._value % y._value));
            }
            else
                throw new DivideByZeroException(SQLResource.s_divideByZeroMessage);
        }

        // Bitwise operators
        public static SqlInt16 operator &(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? Null : new SqlInt16((short)(x._value & y._value));
        }

        public static SqlInt16 operator |(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? Null : new SqlInt16(unchecked((short)((ushort)x._value | (ushort)y._value)));
        }

        public static SqlInt16 operator ^(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? Null : new SqlInt16((short)(x._value ^ y._value));
        }

        // Implicit conversions

        // Implicit conversion from SqlBoolean to SqlInt16
        public static explicit operator SqlInt16(SqlBoolean x)
        {
            return x.IsNull ? Null : new SqlInt16(x.ByteValue);
        }

        // Implicit conversion from SqlByte to SqlInt16
        public static implicit operator SqlInt16(SqlByte x)
        {
            return x.IsNull ? Null : new SqlInt16(x.Value);
        }

        // Explicit conversions

        // Explicit conversion from SqlInt32 to SqlInt16
        public static explicit operator SqlInt16(SqlInt32 x)
        {
            if (x.IsNull)
                return Null;

            int value = x.Value;
            if (value > short.MaxValue || value < short.MinValue)
                throw new OverflowException(SQLResource.s_arithOverflowMessage);
            else
                return new SqlInt16((short)value);
        }

        // Explicit conversion from SqlInt64 to SqlInt16
        public static explicit operator SqlInt16(SqlInt64 x)
        {
            if (x.IsNull)
                return Null;

            long value = x.Value;
            if (value > short.MaxValue || value < short.MinValue)
                throw new OverflowException(SQLResource.s_arithOverflowMessage);
            else
                return new SqlInt16((short)value);
        }

        // Explicit conversion from SqlSingle to SqlInt16
        public static explicit operator SqlInt16(SqlSingle x)
        {
            if (x.IsNull)
                return Null;

            float value = x.Value;
            if (value < short.MinValue || value > short.MaxValue)
                throw new OverflowException(SQLResource.s_arithOverflowMessage);
            else
                return new SqlInt16((short)value);
        }

        // Explicit conversion from SqlDouble to SqlInt16
        public static explicit operator SqlInt16(SqlDouble x)
        {
            if (x.IsNull)
                return Null;

            double value = x.Value;
            if (value < short.MinValue || value > short.MaxValue)
                throw new OverflowException(SQLResource.s_arithOverflowMessage);
            else
                return new SqlInt16((short)value);
        }

        // Explicit conversion from SqlMoney to SqlInt16
        public static explicit operator SqlInt16(SqlMoney x)
        {
            return x.IsNull ? Null : new SqlInt16(checked((short)x.ToInt32()));
        }

        // Explicit conversion from SqlDecimal to SqlInt16
        public static explicit operator SqlInt16(SqlDecimal x)
        {
            return (SqlInt16)(SqlInt32)x;
        }

        // Explicit conversion from SqlString to SqlInt16
        public static explicit operator SqlInt16(SqlString x)
        {
            return x.IsNull ? Null : new SqlInt16(short.Parse(x.Value, null));
        }

        // Overloading comparison operators
        public static SqlBoolean operator ==(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x._value == y._value);
        }

        public static SqlBoolean operator !=(SqlInt16 x, SqlInt16 y)
        {
            return !(x == y);
        }

        public static SqlBoolean operator <(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x._value < y._value);
        }

        public static SqlBoolean operator >(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x._value > y._value);
        }

        public static SqlBoolean operator <=(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x._value <= y._value);
        }

        public static SqlBoolean operator >=(SqlInt16 x, SqlInt16 y)
        {
            return (x.IsNull || y.IsNull) ? SqlBoolean.Null : new SqlBoolean(x._value >= y._value);
        }

        //--------------------------------------------------
        // Alternative methods for overloaded operators
        //--------------------------------------------------

        // Alternative method for operator ~
        public static SqlInt16 OnesComplement(SqlInt16 x)
        {
            return ~x;
        }

        // Alternative method for operator +
        public static SqlInt16 Add(SqlInt16 x, SqlInt16 y)
        {
            return x + y;
        }
        // Alternative method for operator -
        public static SqlInt16 Subtract(SqlInt16 x, SqlInt16 y)
        {
            return x - y;
        }

        // Alternative method for operator *
        public static SqlInt16 Multiply(SqlInt16 x, SqlInt16 y)
        {
            return x * y;
        }

        // Alternative method for operator /
        public static SqlInt16 Divide(SqlInt16 x, SqlInt16 y)
        {
            return x / y;
        }

        // Alternative method for operator %
        public static SqlInt16 Mod(SqlInt16 x, SqlInt16 y)
        {
            return x % y;
        }

        public static SqlInt16 Modulus(SqlInt16 x, SqlInt16 y)
        {
            return x % y;
        }

        // Alternative method for operator &
        public static SqlInt16 BitwiseAnd(SqlInt16 x, SqlInt16 y)
        {
            return x & y;
        }

        // Alternative method for operator |
        public static SqlInt16 BitwiseOr(SqlInt16 x, SqlInt16 y)
        {
            return x | y;
        }

        // Alternative method for operator ^
        public static SqlInt16 Xor(SqlInt16 x, SqlInt16 y)
        {
            return x ^ y;
        }

        // Alternative method for operator ==
        public static SqlBoolean Equals(SqlInt16 x, SqlInt16 y)
        {
            return (x == y);
        }

        // Alternative method for operator !=
        public static SqlBoolean NotEquals(SqlInt16 x, SqlInt16 y)
        {
            return (x != y);
        }

        // Alternative method for operator <
        public static SqlBoolean LessThan(SqlInt16 x, SqlInt16 y)
        {
            return (x < y);
        }

        // Alternative method for operator >
        public static SqlBoolean GreaterThan(SqlInt16 x, SqlInt16 y)
        {
            return (x > y);
        }

        // Alternative method for operator <=
        public static SqlBoolean LessThanOrEqual(SqlInt16 x, SqlInt16 y)
        {
            return (x <= y);
        }

        // Alternative method for operator >=
        public static SqlBoolean GreaterThanOrEqual(SqlInt16 x, SqlInt16 y)
        {
            return (x >= y);
        }

        // Alternative method for conversions.

        public SqlBoolean ToSqlBoolean()
        {
            return (SqlBoolean)this;
        }

        public SqlByte ToSqlByte()
        {
            return (SqlByte)this;
        }

        public SqlDouble ToSqlDouble()
        {
            return this;
        }

        public SqlInt32 ToSqlInt32()
        {
            return this;
        }

        public SqlInt64 ToSqlInt64()
        {
            return this;
        }

        public SqlMoney ToSqlMoney()
        {
            return this;
        }

        public SqlDecimal ToSqlDecimal()
        {
            return this;
        }

        public SqlSingle ToSqlSingle()
        {
            return this;
        }

        public SqlString ToSqlString()
        {
            return (SqlString)this;
        }

        // IComparable
        // Compares this object to another object, returning an integer that
        // indicates the relationship.
        // Returns a value less than zero if this < object, zero if this = object,
        // or a value greater than zero if this > object.
        // null is considered to be less than any instance.
        // If object is not of same type, this method throws an ArgumentException.
        public int CompareTo(object value)
        {
            if (value is SqlInt16)
            {
                SqlInt16 i = (SqlInt16)value;

                return CompareTo(i);
            }
            throw ADP.WrongType(value.GetType(), typeof(SqlInt16));
        }

        public int CompareTo(SqlInt16 value)
        {
            // If both Null, consider them equal.
            // Otherwise, Null is less than anything.
            if (IsNull)
                return value.IsNull ? 0 : -1;
            else if (value.IsNull)
                return 1;

            if (this < value) return -1;
            if (this > value) return 1;
            return 0;
        }

        // Compares this instance with a specified object
        public override bool Equals(object value)
        {
            if (!(value is SqlInt16))
            {
                return false;
            }

            SqlInt16 i = (SqlInt16)value;

            if (i.IsNull || IsNull)
                return (i.IsNull && IsNull);
            else
                return (this == i).Value;
        }

        // For hashing purpose
        public override int GetHashCode()
        {
            return IsNull ? 0 : Value.GetHashCode();
        }

        XmlSchema IXmlSerializable.GetSchema() { return null; }

        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            string isNull = reader.GetAttribute("nil", XmlSchema.InstanceNamespace);
            if (isNull != null && XmlConvert.ToBoolean(isNull))
            {
                // Read the next value.
                reader.ReadElementString();
                _fNotNull = false;
            }
            else
            {
                _value = XmlConvert.ToInt16(reader.ReadElementString());
                _fNotNull = true;
            }
        }

        void IXmlSerializable.WriteXml(XmlWriter writer)
        {
            if (IsNull)
            {
                writer.WriteAttributeString("xsi", "nil", XmlSchema.InstanceNamespace, "true");
            }
            else
            {
                writer.WriteString(XmlConvert.ToString(_value));
            }
        }

        public static XmlQualifiedName GetXsdType(XmlSchemaSet schemaSet)
        {
            return new XmlQualifiedName("short", XmlSchema.Namespace);
        }

        public static readonly SqlInt16 Null = new SqlInt16(true);
        public static readonly SqlInt16 Zero = new SqlInt16(0);
        public static readonly SqlInt16 MinValue = new SqlInt16(short.MinValue);
        public static readonly SqlInt16 MaxValue = new SqlInt16(short.MaxValue);
    } // SqlInt16
} // namespace System.Data.SqlTypes


text:
<?php

namespace Lunr\Corona\Tests;

/**
 * This class contains tests for the JsonView class.
 *
 * @covers     Lunr\Corona\JsonView
 */
class JsonViewPrintFatalErrorTest extends JsonViewTest
{

    /**
     * Test that print_fatal_error() does not print an error page if there is no error.
     *
     * @covers   Lunr\Corona\JsonView::print_fatal_error
     */
    public function testPrintFatalErrorPrintsNothingIfNoError(): void
    {
        $this->mock_function('error_get_last', function (){ return NULL;});

        $this->expectOutputString('');

        $this->class->print_fatal_error();

        $this->unmock_function('error_get_last');
    }

    /**
     * Test that print_fatal_error() does not print an error page if there is no fatal error.
     *
     * @covers   Lunr\Corona\JsonView::print_fatal_error
     */
    public function testPrintFatalErrorPrintsNothingIfErrorNotFatal(): void
    {
        $this->mock_function('error_get_last', function (){return [ 'type' => 8, 'message' => 'Message', 'file' => 'index.php', 'line' => 2 ];});

        $this->expectOutputString('');

        $this->class->print_fatal_error();

        $this->unmock_function('error_get_last');
    }

    /**
     * Test that print_fatal_error() does prints a json object if there is a fatal error.
     *
     * @requires PHP 5.5.12
     * @covers   Lunr\Corona\JsonView::print_fatal_error
     */
    public function testPrintFatalErrorPrintsPrettyJson(): void
    {
        $this->mock_function('error_get_last', function (){ return [ 'type' => 1, 'message' => 'Message', 'file' => 'index.php', 'line' => 2 ];});
        $this->mock_function('header', function (){});

        $this->request->expects($this->once())
                      ->method('__get')
                      ->with($this->equalTo('sapi'))
                      ->will($this->returnValue('cli'));

        $this->expectOutputMatchesFile(TEST_STATICS . '/Corona/json_error.json');

        $this->class->print_fatal_error();

        $this->unmock_function('error_get_last');
        $this->unmock_function('header');
    }

    /**
     * Test that print_fatal_error() does prints a json object if there is a fatal error.
     *
     * @covers   Lunr\Corona\JsonView::print_fatal_error
     */
    public function testPrintFatalErrorForWebPrintsJson(): void
    {
        $this->mock_function('error_get_last', function (){ return [ 'type' => 1, 'message' => 'Message', 'file' => 'index.php', 'line' => 2 ];});
        $this->mock_function('header', function (){});

        $this->request->expects($this->once())
                      ->method('__get')
                      ->with($this->equalTo('sapi'))
                      ->will($this->returnValue('web'));

        $this->expectOutputString('{"data":{},"status":{"code":500,"message":"Message in index.php on line 2"}}');

        $this->class->print_fatal_error();

        $this->unmock_function('error_get_last');
        $this->unmock_function('header');
    }

}

?>

redpajama_set_name: RedPajamaGithub


text:
package com.sourcesense.stone.jcr.modeshape.server.performances;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;

/**
 * Performance test to check performance of queries on sub-trees.
 */
class DescendantSearchTest extends AbstractTest {

    private static final int NODE_COUNT = 100;

    private Session session;

    private Node root;

    @SuppressWarnings("deprecation")
    protected Query createQuery(QueryManager manager, int i)
            throws RepositoryException {
        return manager.createQuery("/jcr:root/testroot//element(*,nt:base)[@testcount=" + i + "]", Query.XPATH);
    }

    public void beforeSuite() throws RepositoryException {
        session = getRepository().login(getCredentials());

        root = session.getRootNode().addNode("testroot", "nt:unstructured");
        for (int i = 0; i < NODE_COUNT; i++) {
            Node node = root.addNode("node" + i, "nt:unstructured");
            for (int j = 0; j < NODE_COUNT; j++) {
                Node child = node.addNode("node" + j, "nt:unstructured");
                child.setProperty("testcount", j);
            }
            session.save();
        }
    }

    public void runTest() throws Exception {
        QueryManager manager = session.getWorkspace().getQueryManager();
        for (int i = 0; i < NODE_COUNT; i++) {
            Query query = createQuery(manager, i);
            NodeIterator iterator = query.execute().getNodes();
            while (iterator.hasNext()) {
                Node node = iterator.nextNode();
                if (node.getProperty("testcount").getLong() != i) {
                    throw new Exception("Invalid test result: " + node.getPath());
                }
            }
        }
    }

    public void afterSuite() throws RepositoryException {
        for (int i = 0; i < NODE_COUNT; i++) {
            root.getNode("node" + i).remove();
            session.save();
        }

        root.remove();
        session.save();
        session.logout();
    }

}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Module: TracksAttributes::TacksAttributesInternal::ClassMethods

    — Documentation by YARD 0.8.4.1

</title>

  <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />

    Index (C) »
    TracksAttributes » TacksAttributesInternal
     »
    ClassMethods

(no frames)

      Class List

      Method List

      File List

Module: TracksAttributes::TacksAttributesInternal::ClassMethods

Defined in:

lib/tracks_attributes.rb

      Instance Method Summary
      (collapse)

      - (Object) accessors

return an array of all of the attributes that are not in active record.

      - (Object) attr_accessor(*vars)

override attr_accessor to track accessors for an TracksAttributes.

      - (Object) attr_reader(*vars)

override attr_reader to track accessors for an TracksAttributes.

      - (Object) attr_writer(*vars)

override attr_writer to track accessors for an TracksAttributes.

Instance Method Details

    - (<tt>Object</tt>) accessors

return an array of all of the attributes that are not in active record

60
61
62

# File 'lib/tracks_attributes.rb', line 60

def accessors
  self.tracked_attrs ||= []
end

    - (<tt>Object</tt>) attr_accessor(*vars)

override attr_accessor to track accessors for an TracksAttributes

42
43
44
45

# File 'lib/tracks_attributes.rb', line 42

def attr_accessor(*vars)
  tracked_attrs.concat vars if tracked_attrs
  super
end

    - (<tt>Object</tt>) attr_reader(*vars)

override attr_reader to track accessors for an TracksAttributes

48
49
50
51

# File 'lib/tracks_attributes.rb', line 48

def attr_reader(*vars)
  tracked_attrs.concat vars if tracked_attrs
  super
end

    - (<tt>Object</tt>) attr_writer(*vars)

override attr_writer to track accessors for an TracksAttributes

54
55
56
57

# File 'lib/tracks_attributes.rb', line 54

def attr_writer(*vars)
  tracked_attrs.concat vars if tracked_attrs
  super
end

  Generated on Sat Feb 16 14:59:36 2013 by
  yard
  0.8.4.1 (ruby-1.9.3).


text:
Coins

Current Coins:

Add Coins

				<button class="btn btn-success">Add to Coins</button>


text:
drop schema if exists bm_ao cascade;
create schema bm_ao;
set search_path to bm_ao;

-- end_ignore

CREATE TABLE outer_table (
    flex_value_id numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    language character varying(4) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    last_update_date date ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    last_updated_by numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    creation_date date ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    created_by numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    last_update_login numeric(10,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    description character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    source_lang character varying(4) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    flex_value_meaning character varying(150) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    legalhold character varying(5) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    legaldescription character varying(255) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    dataowner character varying(255) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    purgedate date ENCODING (compresstype=None,compresslevel=1,blocksize=32768)
)
WITH (appendonly=true, orientation=column, compresstype=None) DISTRIBUTED BY (flex_value_id);

set allow_system_table_mods="DML";
UPDATE pg_class
SET
	relpages = 1::int,
	reltuples = 0.0::real
WHERE relname = 'outer_table' AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'ofa_applsys');
UPDATE pg_class
SET
	relpages = 64::int,
	reltuples = 61988.0::real
WHERE relname = 'outer_table' AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'applsys');

CREATE TABLE inner_table (
    flex_value_set_id numeric(10,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    flex_value_id numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    flex_value character varying(150) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    last_update_date date ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    last_updated_by numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    creation_date date ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    created_by numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    last_update_login numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    enabled_flag character varying(1) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    summary_flag character varying(1) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    start_date_active date ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    end_date_active date ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    parent_flex_value_low character varying(60) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    parent_flex_value_high character varying(60) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    structured_hierarchy_level numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    hierarchy_level character varying(30) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    compiled_value_attributes character varying(2000) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    value_category character varying(30) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute1 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute2 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute3 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute4 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute5 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute6 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute7 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute8 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute9 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute10 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute11 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute12 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute13 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute14 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute15 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute16 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute17 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute18 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute19 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute20 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute21 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute22 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute23 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute24 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute25 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute26 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute27 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute28 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute29 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute30 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute31 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute32 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute33 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute34 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute35 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute36 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute37 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute38 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute39 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute40 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute41 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute42 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute43 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute44 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute45 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute46 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute47 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute48 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute49 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute50 character varying(240) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    attribute_sort_order numeric(15,0) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    legalhold character varying(5) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    legaldescription character varying(255) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    dataowner character varying(255) ENCODING (compresstype=None,compresslevel=1,blocksize=32768),
    purgedate date ENCODING (compresstype=None,compresslevel=1,blocksize=32768)
)
WITH (appendonly=true, orientation=column, compresstype=None) DISTRIBUTED BY (flex_value_set_id ,flex_value_id);

CREATE INDEX inner_table_idx ON inner_table USING btree (flex_value_id);
UPDATE pg_class
SET
	relpages = 64::int,
	reltuples = 30994.0::real
WHERE relname = 'inner_table' AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = 'applsys');

insert into outer_table values(12345,'ZHS');
insert into outer_table values(012345,'ZHS');
insert into inner_table values(54321,12345);
insert into inner_table values(654321,123456);

CREATE TABLE foo(fid numeric(10,0));
insert into foo VALUES(54321);

-- start_ignore

set optimizer_segments=64;
set optimizer_enable_bitmapscan=on;
set optimizer_enable_hashjoin=off;
select disable_xform('CXformInnerJoin2IndexGetApply');

-- end_ignore

SELECT fid FROM
(SELECT b1.flex_value_set_id, b1.flex_value_id
FROM
inner_table b1,
outer_table c1
WHERE
b1.flex_value_id = c1.flex_value_id
and c1.language = 'ZHS') bar,
foo
WHERE foo.fid = bar.flex_value_set_id;

-- double free mixed bitmap indexes (StreamBitmap with TIDBitmap)
CREATE TABLE bmcrash (
    btree_col2 date DEFAULT now(),
    bitmap_col text NOT NULL,
    btree_col1 character varying(50) NOT NULL,
    dist_col serial
)
WITH (appendonly=true, compresslevel=5, compresstype=zlib) DISTRIBUTED BY (dist_col);

CREATE INDEX bm_idx ON bmcrash USING bitmap (bitmap_col);
CREATE INDEX bt_idx ON bmcrash USING btree (btree_col1);
CREATE INDEX bt_idx_2 ON bmcrash USING btree (btree_col2);

INSERT INTO bmcrash (btree_col2, bitmap_col, btree_col1)
SELECT date '2015-01-01' + (i % (365 * 2)), i % 1000, 'abcdefg' || (i% 1000)
from generate_series(1,10000) as i;

select count(1) from bmcrash where bitmap_col = '999' AND btree_col1 = 'abcdefg999';
select count(1) from bmcrash where bitmap_col = '999' OR btree_col1 = 'abcdefg999';
select count(1) from bmcrash where bitmap_col = '999' OR btree_col1 = 'abcdefg999' AND btree_col2 = '2015-01-01';
select count(1) from bmcrash where bitmap_col = '999' AND btree_col1 = 'abcdefg999' OR btree_col2 = '2015-01-01';

select count(1) from bmcrash where btree_col1 = 'abcdefg999' AND bitmap_col = '999';
select count(1) from bmcrash where btree_col1 = 'abcdefg999' OR bitmap_col = '999' AND btree_col2 = '2015-01-01';
select count(1) from bmcrash where btree_col1 = 'abcdefg999' AND bitmap_col = '999' OR btree_col2 = '2015-01-01';
select count(1) from bmcrash where btree_col1 = 'abcdefg999' AND btree_col2 = '2015-01-01' OR bitmap_col = '999';
select count(1) from bmcrash where btree_col1 = 'abcdefg999' AND btree_col2 = '2015-01-01' AND bitmap_col = '999';
select count(1) from bmcrash where btree_col1 = 'abcdefg999' OR btree_col2 = '2015-01-01' AND bitmap_col = '999';
select count(1) from bmcrash where btree_col1 = 'abcdefg999' OR btree_col2 = '2015-01-01' OR bitmap_col = '999';

set enable_bitmapscan=on;
set enable_hashjoin=off;
set enable_indexscan=on;
set enable_nestloop=on;
set enable_seqscan=off;

select count(1) from bmcrash where btree_col1 = 'abcdefg999' AND bitmap_col = '999' OR bitmap_col = '888' OR btree_col2 = '2015-01-01';
select count(1) from bmcrash b1, bmcrash b2 where b1.bitmap_col = b2.bitmap_col or b1.bitmap_col = '999' and b1.btree_col1 = 'abcdefg999';

set optimizer_enable_hashjoin=off;
with bm as (select * from bmcrash where btree_col1 = 'abcdefg999' AND bitmap_col = '999' OR bitmap_col = '888' OR btree_col2 = '2015-01-01')
select count(1) from bm b1, bm b2 where b1.dist_col = b2.dist_col;

-- qual with like, any.
with bm as (select * from bmcrash where (btree_col1 like 'abcde%') AND bitmap_col in ('999', '888'))
select count(1) from bm b1, bm b2 where b1.dist_col = b2.dist_col;

-- start_ignore
drop schema bm_ao cascade;
-- end_ignore


text:
    #include <atlcoll.h>
    #include <cstringt.h>
    #include <atlsimpstr.h>
    #include <atlstr.h>
#endif

namespace brdm = boost::range_detail_microsoft;

#if !(_ATL_VER < 0x0700)

template< class ArrayT, class SampleRange >
bool test_init_auto_ptr_array(ArrayT& arr, SampleRange& sample)
{
    typedef typename boost::range_iterator<SampleRange>::type iter_t;

    for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
        arr.Add(*it); // moves ownership
    }

    return boost::distance(arr) == boost::distance(sample);
}

template< class ListT, class SampleRange >
bool test_init_auto_ptr_list(ListT& lst, SampleRange& sample)
{
    typedef typename boost::range_iterator<SampleRange>::type iter_t;
    typedef typename boost::range_value<SampleRange>::type val_t;

    for (iter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
        lst.AddTail(*it); // moves ownership
    }

    return boost::distance(lst) == boost::distance(sample);
}

// Workaround:
// CRBTree provides no easy access function, but yes, it is the range!
//
template< class AtlMapT, class KeyT, class MappedT >
bool test_atl_map_has(AtlMapT& map, const KeyT& k, const MappedT m)
{
    typedef typename boost::range_iterator<AtlMapT>::type iter_t;

    for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
        if (it->m_key == k && it->m_value == m)
            return true;
    }

    return false;
}

template< class AtlMapT, class MapT >
bool test_atl_map(AtlMapT& map, const MapT& sample)
{
    typedef typename boost::range_iterator<AtlMapT>::type iter_t;
    typedef typename boost::range_const_iterator<MapT>::type siter_t;

    bool result = true;

    result = result && (boost::distance(map) == boost::distance(sample));
    if (!result)
        return false;

    {
        for (iter_t it = boost::begin(map), last = boost::end(map); it != last; ++it) {
            result = result && brdm::test_find_key_and_mapped(sample, std::make_pair(it->m_key, it->m_value));
        }
    }

    {
        for (siter_t it = boost::begin(sample), last = boost::end(sample); it != last; ++it) {
            result = result && (test_atl_map_has)(map, it->first, it->second);
        }
    }

    return result;
}

template< class MapT, class SampleMap >
bool test_init_atl_multimap(MapT& map, const SampleMap& sample)
{
    typedef typename boost::range_const_iterator<SampleMap>::type iter_t;

    for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
        map.Insert(it->first, it->second);
    }

    return boost::distance(map) == boost::distance(sample);
}

// arrays
//

template< class Range >
void test_CAtlArray(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef ATL::CAtlArray<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, val_t const*>::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_array(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class ValT, class Range >
void test_CAutoPtrArray(Range& sample)
{
    typedef ValT val_t;

    typedef ATL::CAutoPtrArray<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, boost::indirect_iterator< ATL::CAutoPtr<val_t> *> >::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, boost::indirect_iterator< ATL::CAutoPtr<val_t> const*> >::value ));

    rng_t rng;
    BOOST_CHECK( ::test_init_auto_ptr_array(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class I, class Range >
void test_CInterfaceArray(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef ATL::CInterfaceArray<I> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, ATL::CComQIPtr<I> * >::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, ATL::CComQIPtr<I> const* >::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_array(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

// lists
//

template< class Range >
void test_CAtlList(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef ATL::CAtlList<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t,       val_t> >::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  < rng_t, brdm::list_iterator<rng_t const, val_t const> >::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_list(rng, sample) );
    BOOST_CHECK( brdm::test_bidirectional(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class ValT, class Range >
void test_CAutoPtrList(Range& sample)
{
    typedef ValT val_t;

    typedef ATL::CAutoPtrList<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t,       ATL::CAutoPtr<val_t> > > >::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  < rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t const, ATL::CAutoPtr<val_t> const> > >::value ));

    rng_t rng;
    BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) );
    BOOST_CHECK( brdm::test_bidirectional(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class ValT, class Range >
void test_CHeapPtrList(const Range& sample)
{
    typedef ValT val_t;

    typedef ATL::CHeapPtrList<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t,       ATL::CHeapPtr<val_t> > > >::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  < rng_t, boost::indirect_iterator< brdm::list_iterator<rng_t const, ATL::CHeapPtr<val_t> const> > >::value ));

    rng_t rng;
    BOOST_CHECK( ::test_init_auto_ptr_list(rng, sample) );
    BOOST_CHECK( brdm::test_bidirectional(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class I, class Range >
void test_CInterfaceList(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef ATL::CInterfaceList<I> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter< rng_t, brdm::list_iterator<rng_t,       ATL::CComQIPtr<I> > >::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  < rng_t, brdm::list_iterator<rng_t const, ATL::CComQIPtr<I> const> >::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_list(rng, sample) );
    BOOST_CHECK( brdm::test_bidirectional(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

// strings
//

template< class Range >
void test_CSimpleStringT(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
        ATL::CAtlStringA,
        ATL::CAtlStringW
    >::type derived_t;

    typedef ATL::CSimpleStringT<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, typename rng_t::PCXSTR>::value ));

    derived_t drng;
    rng_t& rng = drng;
    BOOST_CHECK( brdm::test_init_string(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    // BOOST_CHECK( brdm::test_emptiness(rng) ); no default constructible
}

template< int n, class Range >
void test_CFixedStringT(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
        ATL::CAtlStringA,
        ATL::CAtlStringW
    >::type base_t;

    typedef ATL::CFixedStringT<base_t, n> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, typename rng_t::PCXSTR>::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_string(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class Range >
void test_CStringT(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef typename boost::mpl::if_< boost::is_same<val_t, char>,
        ATL::CAtlStringA, // == CStringT<char, X>
        ATL::CAtlStringW  // == CStringT<wchar_t, X>
    >::type rng_t;

    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, typename rng_t::PXSTR>::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, typename rng_t::PCXSTR>::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_string(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class Range >
void test_CStaticString(const Range& sample)
{
#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE)
    {
        typedef ATL::CStaticString<char, 20> rng_t;
        BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, char const *>::value ));
        BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, char const *>::value ));

        rng_t rng("hello static string");
        BOOST_CHECK( *(boost::begin(rng)+4) == 'o' );
        BOOST_CHECK( *(boost::end(rng)-3) == 'i' );
    }

    {
        typedef ATL::CStaticString<wchar_t, 40> rng_t;
        BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, wchar_t const *>::value ));
        BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, wchar_t const *>::value ));

        rng_t rng(L"hello static string");
        BOOST_CHECK( *(boost::begin(rng)+4) == L'o' );
        BOOST_CHECK( *(boost::end(rng)-3) == L'i' );
    }
#endif

    (void)sample; // unused
}

#endif // !(_ATL_VER < 0x0700)

template< class Range >
void test_CComBSTR(const Range& sample)
{
    typedef ATL::CComBSTR rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, OLECHAR *>::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, OLECHAR const*>::value ));

    rng_t rng(OLESTR("hello CComBSTR range!"));
    BOOST_CHECK( brdm::test_equals(rng, std::string("hello CComBSTR range!")) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );

    (void)sample; // unused
}

// simples
//

template< class Range >
void test_CSimpleArray(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef ATL::CSimpleArray<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, val_t const*>::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_array(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

template< class Range >
void test_CSimpleMap(const Range& sample)
{
#if !defined(BOOST_RANGE_ATL_NO_TEST_UNDOCUMENTED_RANGE)

    typedef ATL::CSimpleMap<int, double> rng_t;

    rng_t rng;
    rng.Add(3, 3.0);
    rng.Add(4, 2.0);

    BOOST_CHECK( boost::begin(rng)->get<0>() == 3.0 );
    BOOST_CHECK( (boost::end(rng)-1)->get<1>() == 2.0 );

#endif

    (void)sample; // unused
}

template< class Range >
void test_CSimpleValArray(const Range& sample)
{
    typedef typename boost::range_value<Range>::type val_t;

    typedef ATL::CSimpleArray<val_t> rng_t;
    BOOST_STATIC_ASSERT(( brdm::test_mutable_iter<rng_t, val_t *>::value ));
    BOOST_STATIC_ASSERT(( brdm::test_const_iter  <rng_t, val_t const*>::value ));

    rng_t rng;
    BOOST_CHECK( brdm::test_init_array(rng, sample) );
    BOOST_CHECK( brdm::test_random_access(rng) );
    BOOST_CHECK( brdm::test_emptiness(rng) );
}

// maps
//

template< class MapT >
void test_CAtlMap(const MapT& sample)
{
    typedef typename MapT::key_type k_t;
    typedef typename MapT::mapped_type m_t;

    typedef ATL::CAtlMap<k_t, m_t> rng_t;

    rng_t rng;
    boost::function_requires< boost::ForwardRangeConcept<rng_t> >();
    BOOST_CHECK( brdm::test_init_map(rng, sample) );
    BOOST_CHECK( ::test_atl_map(rng, sample) );
}

template< class MapT >
void test_CRBTree(const MapT& sample)
{
    typedef typename MapT::key_type k_t;
    typedef typename MapT::mapped_type m_t;

    typedef ATL::CRBMap<k_t, m_t> derived_t;
    typedef ATL::CRBTree<k_t, m_t> rng_t;

    derived_t drng;
    rng_t& rng = drng;

    boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
    BOOST_CHECK( brdm::test_init_map(drng, sample) );
    BOOST_CHECK( ::test_atl_map(rng, sample) );
}

template< class MapT >
void test_CRBMap(const MapT& sample)
{
    typedef typename MapT::key_type k_t;
    typedef typename MapT::mapped_type m_t;

    typedef ATL::CRBMap<k_t, m_t> rng_t;

    rng_t rng;
    boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
    BOOST_CHECK( brdm::test_init_map(rng, sample) );
    BOOST_CHECK( ::test_atl_map(rng, sample) );
}

template< class MapT >
void test_CRBMultiMap(const MapT& sample)
{
    typedef typename MapT::key_type k_t;
    typedef typename MapT::mapped_type m_t;

    typedef ATL::CRBMultiMap<k_t, m_t> rng_t;

    rng_t rng;
    boost::function_requires< boost::BidirectionalRangeConcept<rng_t> >();
    BOOST_CHECK( ::test_init_atl_multimap(rng, sample) );
    BOOST_CHECK( ::test_atl_map(rng, sample) );
}

// main test
//

void test_atl()
{

    // ordinary ranges
    //
    {
        std::string sample("rebecca judy and mary whiteberry chat monchy");
#if !(_ATL_VER < 0x0700)
        ::test_CAtlArray(sample);
        ::test_CAtlList(sample);
        ::test_CSimpleStringT(sample);
        ::test_CFixedStringT<44>(sample);
        ::test_CStringT(sample);
        ::test_CStaticString(sample);
#endif
        ::test_CComBSTR(sample);
        ::test_CSimpleArray(sample);
        ::test_CSimpleMap(sample);
        ::test_CSimpleValArray(sample);
    }

    {
        std::wstring sample(L"rebecca judy and mary whiteberry chat monchy");
#if !(_ATL_VER < 0x0700)
        ::test_CAtlArray(sample);
        ::test_CAtlList(sample);
        ::test_CSimpleStringT(sample);
        ::test_CFixedStringT<44>(sample);
        ::test_CStringT(sample);
        ::test_CStaticString(sample);
#endif
        ::test_CComBSTR(sample);
        ::test_CSimpleArray(sample);
        ::test_CSimpleMap(sample);
        ::test_CSimpleValArray(sample);
    }

    // pointer ranges
    //
#if !(_ATL_VER < 0x0700)
    {
        typedef ATL::CAutoPtr<int> ptr_t;
        ptr_t
            ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)),
            ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0));

        ptr_t ptrs[8] = {
            ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7
        };

        boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
        ::test_CAutoPtrArray<int>(workaround);
    }

    {
        typedef ATL::CAutoPtr<int> ptr_t;
        ptr_t
            ptr0(new int(3)), ptr1(new int(4)), ptr2(new int(5)), ptr3(new int(4)),
            ptr4(new int(1)), ptr5(new int(2)), ptr6(new int(4)), ptr7(new int(0));

        ptr_t ptrs[8] = {
            ptr0, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6, ptr7
        };

        boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
        ::test_CAutoPtrList<int>(workaround);
    }

    {
        typedef ATL::CHeapPtr<int> ptr_t;
        ptr_t ptrs[5]; {
            ptrs[0].AllocateBytes(sizeof(int));
            ptrs[1].AllocateBytes(sizeof(int));
            ptrs[2].AllocateBytes(sizeof(int));
            ptrs[3].AllocateBytes(sizeof(int));
            ptrs[4].AllocateBytes(sizeof(int));
        }

        boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+5);
        ::test_CHeapPtrList<int>(workaround);
    }

    {
        typedef ATL::CComQIPtr<IDispatch> ptr_t;
        ptr_t ptrs[8];

        boost::iterator_range< ptr_t * > workaround(ptrs, ptrs+8);
        ::test_CInterfaceArray<IDispatch>(workaround);
        ::test_CInterfaceList<IDispatch>(workaround);
    }
#endif

    // maps
    //
    {
#if !(_ATL_VER < 0x0700)
        std::map<int, std::string> sample; {
            sample[0] = "hello";
            sample[1] = "range";
            sample[2] = "atl";
            sample[3] = "mfc";
            sample[4] = "collections";
        }

        ::test_CAtlMap(sample);
        ::test_CRBTree(sample);
        ::test_CRBMap(sample);
        ::test_CRBMultiMap(sample);
#endif
    }

} // test_atl

#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;

test_suite *
init_unit_test_suite(int argc, char* argv[])
{
    test_suite *test = BOOST_TEST_SUITE("ATL Range Test Suite");
    test->add(BOOST_TEST_CASE(&test_atl));

    (void)argc, (void)argv; // unused
    return test;
}


text:
using System;
using System.Collections.Generic;

namespace UnityEngine.PostProcessing
{
    using UnityObject = Object;

    public sealed class MaterialFactory : IDisposable
    {
        Dictionary<string, Material> m_Materials;

        public MaterialFactory()
        {
            m_Materials = new Dictionary<string, Material>();
        }

        public Material Get(string shaderName)
        {
            Material material;

            if (!m_Materials.TryGetValue(shaderName, out material))
            {
                var shader = Shader.Find(shaderName);

                if (shader == null)
                    throw new ArgumentException(string.Format("Shader not found ({0})", shaderName));

                material = new Material(shader)
                {
                    name = string.Format("PostFX - {0}", shaderName.Substring(shaderName.LastIndexOf("/") + 1)),
                    hideFlags = HideFlags.DontSave
                };

                m_Materials.Add(shaderName, material);
            }

            return material;
        }

        public void Dispose()
        {
            var enumerator = m_Materials.GetEnumerator();
            while (enumerator.MoveNext())
            {
                var material = enumerator.Current.Value;
                GraphicsUtils.Destroy(material);
            }

            m_Materials.Clear();
        }
    }
}


text:
namespace nc {

void MurmurHash3_x64_128(const void* key, const int len, uint32_t seed,
                         uint32_t* h1_out, uint32_t* h2_out);

template <typename T>
struct ValueExtractor {
  void operator()(const T& value, const void** v, size_t* s) const {
    const void* value_ptr = static_cast<const void*>(&value);
    *v = value_ptr;
    *s = sizeof(T);
  }
};

template <>
struct ValueExtractor<std::string> {
  void operator()(const std::string& value, const void** v, size_t* s) const {
    *v = value.data();
    *s = value.size();
  }
};

template <typename T>
struct ValueExtractor<std::vector<T>> {
  void operator()(const std::vector<T>& value, const void** v,
                  size_t* s) const {
    *v = value.data();
    *s = value.size() * sizeof(T);
  }
};

template <typename T, typename V = ValueExtractor<T>>
class BloomFilter {
 public:
  BloomFilter(size_t expected_num_elements,
              double false_positive_probability = 0.0001) {
    double l2 = std::log2(false_positive_probability);
    num_hashes_ = ceil(-l2);
    CHECK(num_hashes_ > 0);

    size_t num_bits = ceil(-1.44 * l2 * expected_num_elements);
    CHECK(num_bits > 0);
    bits_.resize(num_bits);
  }

  void Add(const T& value) {
    uint32_t hash_one;
    uint32_t hash_two;
    HashValue(value, &hash_one, &hash_two);

    for (size_t i = 0; i < num_hashes_; ++i) {
      uint64_t bit_to_set = ComputeNthHash(hash_one, hash_two, i);
      bits_[bit_to_set % bits_.size()] = true;
    }
  }

  bool PossiblyContains(const T& value) const {
    uint32_t hash_one;
    uint32_t hash_two;
    HashValue(value, &hash_one, &hash_two);

    for (size_t i = 0; i < num_hashes_; ++i) {
      uint64_t bit_to_set = ComputeNthHash(hash_one, hash_two, i);
      if (!bits_[bit_to_set % bits_.size()]) {
        return false;
      }
    }

    return true;
  }

  double SaturationFactor() const {
    double total = 0;
    for (bool i : bits_) {
      if (i) {
        ++total;
      }
    }

    return total / bits_.size();
  }

 private:
  static constexpr double kLn2 = 0.6931471805599453;
  static constexpr uint32_t kHashSeed = 42;

  inline uint64_t ComputeNthHash(uint32_t hash_one, uint32_t hash_two,
                                 size_t n) const {
    return hash_one + n * hash_two;
  }

  inline void HashValue(const T& value, uint32_t* hash_one,
                        uint32_t* hash_two) const {
    const void* value_ptr;
    size_t len;
    extractor_(value, &value_ptr, &len);

    MurmurHash3_x64_128(value_ptr, len, kHashSeed, hash_one, hash_two);
  }

  V extractor_;
  size_t num_hashes_;
  std::vector<bool> bits_;
};

}  // namespace nc


text:
<?php

namespace Github\Api\Repository;

use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;

/**
 * @link   https://developer.github.com/v3/repos/branches/
 *
 * @author Brandon Bloodgood <bbloodgood@gmail.com>
 */
class Protection extends AbstractApi
{
    use AcceptHeaderTrait;

    /**
     * Retrieves configured protection for the provided branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#get-branch-protection
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The branch protection information
     */
    public function show($username, $repository, $branch)
    {
        // Preview endpoint
        $this->acceptHeaderValue = 'application/vnd.github.luke-cage-preview+json';

        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection');
    }

    /**
     * Updates the repo's branch protection.
     *
     * @link https://developer.github.com/v3/repos/branches/#update-branch-protection
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The branch protection information
     *
     * @return array The updated branch protection information
     */
    public function update($username, $repository, $branch, array $params = [])
    {
        // Preview endpoint
        $this->acceptHeaderValue = 'application/vnd.github.luke-cage-preview+json';

        return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection', $params);
    }

    /**
     * Remove the repo's branch protection.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-branch-protection
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     */
    public function remove($username, $repository, $branch)
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection');
    }

    /**
     * Get required status checks of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#get-required-status-checks-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The required status checks information
     */
    public function showStatusChecks($username, $repository, $branch)
    {
        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks');
    }

    /**
     * Update required status checks of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#update-required-status-checks-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The branch status checks information
     *
     * @return array The updated branch status checks information
     */
    public function updateStatusChecks($username, $repository, $branch, array $params = [])
    {
        return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks', $params);
    }

    /**
     * Remove required status checks of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-required-status-checks-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     */
    public function removeStatusChecks($username, $repository, $branch)
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks');
    }

    /**
     * List required status checks contexts of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#list-required-status-checks-contexts-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The required status checks contexts information
     */
    public function showStatusChecksContexts($username, $repository, $branch)
    {
        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts');
    }

    /**
     * Replace required status checks contexts of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#replace-required-status-checks-contexts-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The branch status checks contexts information
     *
     * @return array The new branch status checks contexts information
     */
    public function replaceStatusChecksContexts($username, $repository, $branch, array $params = [])
    {
        return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params);
    }

    /**
     * Add required status checks contexts of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#add-required-status-checks-contexts-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The branch status checks contexts information
     *
     * @return array The updated branch status checks contexts information
     */
    public function addStatusChecksContexts($username, $repository, $branch, array $params = [])
    {
        return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params);
    }

    /**
     * Remove required status checks contexts of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-required-status-checks-contexts-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The branch status checks contexts information
     *
     * @return array The updated branch status checks contexts information
     */
    public function removeStatusChecksContexts($username, $repository, $branch, array $params = [])
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params);
    }

    /**
     * Get pull request review enforcement of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#get-pull-request-review-enforcement-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The pull request review enforcement information
     */
    public function showPullRequestReviewEnforcement($username, $repository, $branch)
    {
        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_pull_request_reviews');
    }

    /**
     * Update pull request review enforcement of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#update-pull-request-review-enforcement-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The branch status checks information
     *
     * @return array The updated branch status checks information
     */
    public function updatePullRequestReviewEnforcement($username, $repository, $branch, array $params = [])
    {
        return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_pull_request_reviews', $params);
    }

    /**
     * Remove pull request review enforcement of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-pull-request-review-enforcement-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     */
    public function removePullRequestReviewEnforcement($username, $repository, $branch)
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_pull_request_reviews');
    }

    /**
     * Get admin enforcement of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#get-admin-enforcement-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The admin enforcement information
     */
    public function showAdminEnforcement($username, $repository, $branch)
    {
        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/enforce_admins');
    }

    /**
     * Add admin enforcement of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#add-admin-enforcement-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The updated admin enforcement information
     */
    public function addAdminEnforcement($username, $repository, $branch)
    {
        return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/enforce_admins');
    }

    /**
     * Remove admin enforcement of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     */
    public function removeAdminEnforcement($username, $repository, $branch)
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/enforce_admins');
    }

    /**
     * Get restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#get-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The branch restrictions information
     */
    public function showRestrictions($username, $repository, $branch)
    {
        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions');
    }

    /**
     * Remove restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     */
    public function removeRestrictions($username, $repository, $branch)
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions');
    }

    /**
     * List team restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#list-team-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The branch team restrictions information
     */
    public function showTeamRestrictions($username, $repository, $branch)
    {
        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams');
    }

    /**
     * Replace team restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#replace-team-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The list of team slugs with push access
     *
     * @return array The new branch team restrictions information
     */
    public function replaceTeamRestrictions($username, $repository, $branch, array $params = [])
    {
        return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params);
    }

    /**
     * Add team restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#add-team-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The list of team slugs with push access
     *
     * @return array The branch team restrictions information
     */
    public function addTeamRestrictions($username, $repository, $branch, array $params = [])
    {
        return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params);
    }

    /**
     * Remove team restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-team-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The list of team slugs with push access
     *
     * @return array The updated branch team restrictions information
     */
    public function removeTeamRestrictions($username, $repository, $branch, array $params = [])
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params);
    }

    /**
     * List user restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#list-user-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     *
     * @return array The branch user restrictions information
     */
    public function showUserRestrictions($username, $repository, $branch)
    {
        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users');
    }

    /**
     * Replace user restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#replace-user-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The list of user logins with push access
     *
     * @return array The new branch user restrictions information
     */
    public function replaceUserRestrictions($username, $repository, $branch, array $params = [])
    {
        return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params);
    }

    /**
     * Add user restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#add-user-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The list of user logins with push access
     *
     * @return array The branch user restrictions information
     */
    public function addUserRestrictions($username, $repository, $branch, array $params = [])
    {
        return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params);
    }

    /**
     * Remove user restrictions of protected branch.
     *
     * @link https://developer.github.com/v3/repos/branches/#remove-user-restrictions-of-protected-branch
     *
     * @param string $username   The user who owns the repository
     * @param string $repository The name of the repo
     * @param string $branch     The name of the branch
     * @param array  $params     The list of user logins with push access
     *
     * @return array The updated branch user restrictions information
     */
    public function removeUserRestrictions($username, $repository, $branch, array $params = [])
    {
        return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params);
    }
}


text:
A package for the [atom.io](https://atom.io) editor which
adds syntax highlighting for
[Volt](http://docs.phalconphp.com/en/latest/reference/volt.html) templating engine
which is used in [Phalcon](http://phalconphp.com) PHP framework.

[Converted](http://atom.io/docs/latest/converting-a-text-mate-bundle)
from the [Textmate/SublimeText definitions](https://github.com/phalcon/volt-sublime-textmate)
with some cleanup


text:
{% extends "layout.html" %}
{% block content %}

        <form class="pipelinegroupsform" role="form" action="" method="post">
            <input type="button" class="btn btn-default" id="allgroups" value="Select all groups">
            <input type="button" class="btn btn-default" id="nogroups" value="Unselect all groups">
            {% for pipelinegroup, checked, pipelines in pipelinegroups %}

                    <input type="checkbox" {{ checked }} name="{{ pipelinegroup }}">
                        {{ pipelinegroup }}

            {% endfor %}
            <input type="submit" class="btn btn-default" value="Save pipeline-group selection">
        </form>

{% endblock %}

{% block scripts %}

{% endblock %}


text:
#ifndef __LINUX_RECIPROCAL_DIV_WRAPPER_H
#define __LINUX_RECIPROCAL_DIV_WRAPPER_H

#include <linux/version.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
#include_next <linux/reciprocal_div.h>
#else

#include <linux/types.h>

/*
 * This file describes reciprocical division.
 *
 * This optimizes the (A/B) problem, when A and B are two u32
 * and B is a known value (but not known at compile time)
 *
 * The math principle used is :
 *   Let RECIPROCAL_VALUE(B) be (((1LL << 32) + (B - 1))/ B)
 *   Then A / B = (u32)(((u64)(A) * (R)) >> 32)
 *
 * This replaces a divide by a multiply (and a shift), and
 * is generally less expensive in CPU cycles.
 */

/*
 * Computes the reciprocal value (R) for the value B of the divisor.
 * Should not be called before each reciprocal_divide(),
 * or else the performance is slower than a normal divide.
 */
extern u32 reciprocal_value(u32 B);

static inline u32 reciprocal_divide(u32 A, u32 R)
{
	return (u32)(((u64)A * R) >> 32);
}

#endif /* Linux kernel < 2.6.20 */
#endif /* __LINUX_RECIPROCAL_DIV_WRAPPER_H */


text:
using System;
using NetOffice;
using NetOffice.Attributes;
namespace NetOffice.DAOApi.Enums
{
	 /// <summary>
	 /// SupportByVersion DAO 3.6, 12.0
	 /// </summary>
	[SupportByVersion("DAO", 3.6,12.0)]
	[EntityType(EntityType.IsEnum)]
	public enum QueryDefStateEnum
	{
		 /// <summary>
		 /// SupportByVersion DAO 3.6, 12.0
		 /// </summary>
		 /// <remarks>1</remarks>
		 [SupportByVersion("DAO", 3.6,12.0)]
		 dbQPrepare = 1,

		 /// <summary>
		 /// SupportByVersion DAO 3.6, 12.0
		 /// </summary>
		 /// <remarks>2</remarks>
		 [SupportByVersion("DAO", 3.6,12.0)]
		 dbQUnprepare = 2
	}
}


text:
package com.knowledgecode.cordova.websocket;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import org.apache.cordova.CallbackContext;
import org.json.JSONArray;
import org.json.JSONException;

class TaskRunner implements Runnable {

    interface Task {
        public void execute(JSONArray args, CallbackContext ctx);
    }

    private BlockingQueue<TaskBean> _queue;
    private Map<String, Task> _map;

    public TaskRunner() {
        _queue = new LinkedBlockingQueue<TaskBean>();
        _map = new HashMap<String, Task>();
    }

    public void setTask(String action, Task task) {
        _map.put(action, task);
    }

    public boolean addTaskQueue(TaskBean bean) {
        try {
            _queue.put(bean);
        } catch (InterruptedException e) {
            return false;
        }
        return true;
    }

    @Override
    public void run() {
        while (true) {
            TaskBean task;

            try {
                task = _queue.take();
            } catch (InterruptedException e) {
                _queue.clear();
                _queue = null;
                _map.clear();
                _map = null;
                break;
            }

            String action = task.getAction();
            CallbackContext ctx = task.getCtx();
            JSONArray args = null;

            try {
                args = new JSONArray(task.getRawArgs());
            } catch (JSONException e) {
                ctx.error("JSON");
            }
            _map.get(action).execute(args, ctx);
        }
    }
}


text:
namespace MassTransit.Middleware
{
    using System;
    using System.Reflection;
    using System.Threading;

    /// <summary>
    /// The base for any pipe context proxy, optimized to avoid member access
    /// </summary>
    public abstract class ProxyPipeContext
    {
        readonly PipeContext _parentContext;

        /// <summary>
        /// The parent pipe context for this proxy
        /// </summary>
        protected ProxyPipeContext(PipeContext parentContext)
        {
            _parentContext = parentContext;
        }

        /// <summary>
        /// Returns the CancellationToken for the context (implicit interface)
        /// </summary>
        public virtual CancellationToken CancellationToken => _parentContext.CancellationToken;

        /// <summary>
        /// Returns true if the payload type is included with or supported by the context type
        /// </summary>
        /// <param name="payloadType"></param>
        /// <returns></returns>
        public virtual bool HasPayloadType(Type payloadType)
        {
            return payloadType.GetTypeInfo().IsInstanceOfType(this) || _parentContext.HasPayloadType(payloadType);
        }

        /// <summary>
        /// Attempts to get the specified payload type
        /// </summary>
        /// <param name="payload"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public virtual bool TryGetPayload<T>(out T? payload)
            where T : class
        {
            if (this is T context)
            {
                payload = context;
                return true;
            }

            return _parentContext.TryGetPayload(out payload);
        }

        /// <summary>
        /// Get or add a payload to the context, using the provided payload factory.
        /// </summary>
        /// <param name="payloadFactory">The payload factory, which is only invoked if the payload is not present.</param>
        /// <typeparam name="T">The payload type</typeparam>
        /// <returns></returns>
        public virtual T GetOrAddPayload<T>(PayloadFactory<T> payloadFactory)
            where T : class
        {
            if (this is T context)
                return context;

            return _parentContext.GetOrAddPayload(payloadFactory);
        }

        /// <summary>
        /// Either adds a new payload, or updates an existing payload
        /// </summary>
        /// <param name="addFactory">The payload factory called if the payload is not present</param>
        /// <param name="updateFactory">The payload factory called if the payload already exists</param>
        /// <typeparam name="T">The payload type</typeparam>
        /// <returns></returns>
        public virtual T AddOrUpdatePayload<T>(PayloadFactory<T> addFactory, UpdatePayloadFactory<T> updateFactory)
            where T : class
        {
            if (this is T context)
                return context;

            return _parentContext.AddOrUpdatePayload(addFactory, updateFactory);
        }
    }
}


text:
<?php

namespace Grid\User\Model\User;

use Zork\Rpc\CallableTrait;
use Zork\Rpc\CallableInterface;
use Zork\Model\MapperAwareTrait;
use Zork\Model\MapperAwareInterface;
use Zend\Authentication\AuthenticationService;
use Zork\Authentication\AuthenticationServiceAwareTrait;

/**
 * Rpc
 *
 * @author David Pozsar <david.pozsar@megaweb.hu>
 */
class Rpc implements CallableInterface,
                     MapperAwareInterface
{

    use CallableTrait,
        MapperAwareTrait,
        AuthenticationServiceAwareTrait;

    /**
     * Construct rpc
     *
     * @param   Mapper                  $userMapper
     * @param   AuthenticationService   $authenticationService
     */
    public function __construct( Mapper                 $userMapper,
                                 AuthenticationService  $authenticationService )
    {
        $this->setMapper( $userMapper )
             ->setAuthenticationService( $authenticationService );
    }

    /**
     * Is an email name available
     *
     * @param   string          $email
     * @param   array|object    $fields [optional]
     * @return  bool
     */
    public function isEmailAvailable( $email, $fields = array() )
    {
        $fields = (object) $fields;

        return $this->getMapper()
                    ->isEmailExists(
                          $email,
                          empty( $fields->id ) ? null : $fields->id
                      )
               ? 'user.action.register.email.taken'
               : true;
    }

    /**
     * Is an email not taken
     *
     * @param   string          $email
     * @param   array|object    $fields [optional]
     * @return  bool
     */
    public function isEmailNotTaken( $email, $fields = array() )
    {
        $fields = (object) $fields;

        return $this->getMapper()
                    ->isEmailTaken(
                          $email,
                          empty( $fields->id ) ? null : $fields->id
                      )
               ? 'user.action.register.email.taken'
               : true;
    }

    /**
     * Is a display name available
     *
     * @param   string          $displayName
     * @param   array|object    $fields [optional]
     * @return  bool
     */
    public function isDisplayNameAvailable( $displayName, $fields = array() )
    {
        $fields      = (object) $fields;
        $displayName = Structure::trimDisplayName( $displayName );

        if ( 3 > mb_strlen( $displayName ) )
        {
            return 'user.action.register.displayName.tooShort';
        }

        return $this->getMapper()
                    ->isDisplayNameExists(
                          $displayName,
                          empty( $fields->id ) ? null : $fields->id
                      )
               ? 'user.action.register.displayName.taken'
               : true;
    }

    /**
     * Get user status
     *
     * @return  object
     */
    public function status()
    {
        $auth       = $this->getAuthenticationService();
        $loggedIn   = $auth->hasIdentity();
        $identity   = $loggedIn ? $auth->getIdentity() : null;

        return (object) array(
            'loggedIn'      => $loggedIn,
            'id'            => $loggedIn ? $identity->id            : null,
            'email'         => $loggedIn ? $identity->email         : null,
            'displayName'   => $loggedIn ? $identity->displayName   : null,
        );
    }

}


text:
package Encapsulation.Exercise.P04PizzaCalories;

public class Dough {

//    -	flourType: String
//-	bakingTechnique: String
//-	weight: double

    private String flourType;
    private String bakingTechnique;
    private double weight;

//+ 	Dough (String, String, double)

    public Dough(String flourType, String bakingTechnique, double weight) {
        this.setFlourType(flourType);
        this.setBakingTechnique(bakingTechnique);
        this.setWeight(weight);
    }

//-	setWeight(double): void
//-	setFlourType(String): void
//-	setBakingTechnique(String): void

    private void setFlourType(String flourType) {
        if (!"White".equals(flourType)
                && !"Wholegrain".equals(flourType)){
            throw new IllegalStateException("Invalid type of dough.");
        }
        this.flourType = flourType;
    }

    private void setBakingTechnique(String bakingTechnique) {
        if (!"Crispy".equals(bakingTechnique)
        && !"Chewy".equals(bakingTechnique)
        && !"Homemade".equals(bakingTechnique)){
            throw new IllegalStateException("Invalid type of dough.");
        }
        this.bakingTechnique = bakingTechnique;
    }

    private void setWeight(double weight) {
        if (weight < 1 || weight > 200){
            throw new IllegalStateException("Dough weight should be in the range [1..200].");
        }
        this.weight = weight;
    }

//+	calculateCalories (): double

    public double calculateCalories(){
        return this.weight * 2 * this.getModifierByBakingTechnique() * this.getModifierByFlourType();
    }

    private double getModifierByFlourType() {
        switch (this.flourType){
            case "White": return 1.5;
            case "Wholegrain": return 1.0;
            default: return  0.0;
        }
    }

    private double getModifierByBakingTechnique() {
        switch (this.bakingTechnique){
            case "Crispy": return 0.9;
            case "Chewy": return 1.1;
            case "Homemade": return 1.0;
            default: return  0.0;
        }
    }
}


text:
<link rel="import" href="firebase_query_nodart.html">
<link rel="import" href="firebase_database_behavior.html">

<script type="application/dart" src="firebase_query.dart"></script>


text:
using AutoMapper;
using MakeFriends.Common.Mapping;
using System;
using System.Linq;

namespace MakeFriends.Web.Infrastructure.Mapping
{
    public class AutoMapperProfile : Profile
    {
        public AutoMapperProfile()
        {
            var allTypes = AppDomain
                .CurrentDomain
                .GetAssemblies()
                .Where(a => a.GetName().Name.Contains("MakeFriends"))
                .SelectMany(a => a.GetTypes());

            allTypes
                .Where(t => t.IsClass && !t.IsAbstract
                     && t.GetInterfaces()
                         .Where(i => t.IsGenericType)
                         .Select(i => i.GetGenericTypeDefinition()).Contains(typeof(IMapFrom<>)))
                .Select(t => new
                {
                    Source = t.GetInterfaces()
                              .Where(i => i.IsGenericType)
                              .Select(i => new
                              {
                                  Definition = i.GetGenericTypeDefinition(),
                                  Arguments = i.GetGenericArguments()
                              })
                              .Where(i => i.Definition == typeof(IMapFrom<>))
                              .SelectMany(i => i.Arguments)
                              .First(),
                    Destination = t
                })
                .ToList()
                .ForEach(mapping => this.CreateMap(mapping.Source, mapping.Destination));

            //custom mapping
            allTypes
                .Where(t => t.IsClass && !t.IsAbstract && typeof(IHaveCustomMapping).IsAssignableFrom(t))
                .Select(Activator.CreateInstance)
                .Cast<IHaveCustomMapping>()
                .ToList()
                .ForEach(mapping => mapping.ConfigureMapping(this));

        }

    }
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.gz.javacodegen</groupId>
		<artifactId>javacodegen</artifactId>
		<version>0.0.1</version>
	</parent>

	<artifactId>shell</artifactId>
	<name>shell</name>
	<packaging>jar</packaging>

	<dependencies>
		<dependency>
			<groupId>org.gz.javacodegen</groupId>
			<artifactId>core</artifactId>
			<version>0.0.1</version>
		</dependency>
		<dependency>
			<groupId>org.gz.javacodegen</groupId>
			<artifactId>springroojpa</artifactId>
			<version>0.0.1</version>
		</dependency>
		<dependency>
			<groupId>org.gz.javacodegen</groupId>
			<artifactId>template</artifactId>
			<version>0.0.1</version>
		</dependency>
		<dependency>
			<groupId>com.sun.xml.bind</groupId>
			<artifactId>jaxb-impl</artifactId>
			<version>2.2.7</version>
		</dependency>
		<dependency>
			<groupId>args4j</groupId>
			<artifactId>args4j</artifactId>
			<version>2.0.8</version>
		</dependency>
	</dependencies>
</project>