text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:orientation="vertical"
            android:paddingTop="@dimen/activity_vertical_margin">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <ImageView
                    style="@style/Icon"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:src="@drawable/ic_terrain_grey_600_24dp" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="72dp"
                        android:gravity="center_vertical"
                        android:orientation="vertical">

                        <TextView
                            style="@style/Hint"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="10dp"
                            android:paddingLeft="4dp"
                            android:text="@string/acre"
                            android:textColor="@color/text_54" />

                        <Spinner
                            android:id="@+id/spinner_acre"
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:minHeight="?attr/actionBarSize" />

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <ImageView
                    style="@style/Icon"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:src="@color/transparent" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="72dp"
                        android:gravity="center_vertical"
                        android:orientation="horizontal"
                        android:paddingRight="@dimen/activity_vertical_margin">

                        <android.support.design.widget.TextInputLayout
                            android:id="@+id/layout_area"
                            android:layout_width="0dp"
                            android:layout_height="wrap_content"
                            android:layout_weight="1"
                            app:errorTextAppearance="@style/Hint">

                            <EditText
                                android:id="@+id/text_area"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:hint="@string/area"
                                android:inputType="numberDecimal" />

                        </android.support.design.widget.TextInputLayout>

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:gravity="center_vertical"
                            android:text="@string/hectare_si"
                            style="@style/Subtitle"/>

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginLeft="72dp"
                android:background="@color/text_12" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <ImageView
                    style="@style/Icon"
                    android:layout_width="40dp"
                    android:layout_height="40dp"
                    android:src="@drawable/ic_grape_grey600_24dp" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="72dp"
                        android:gravity="center_vertical"
                        android:orientation="vertical">

                        <TextView
                            style="@style/Hint"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="10dp"
                            android:paddingLeft="4dp"
                            android:text="@string/grape"
                            android:textColor="@color/text_54" />

                        <Spinner
                            android:id="@+id/spinner_grape"
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:minHeight="?attr/actionBarSize" />

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</RelativeLayout>


text:
A set of tools for visualization, processing and analysis (supervised, unsupervised,
image alignment, etc..) of Spatial Transcriptomics datasets.

The package is compatible with the output format of the data generated with the
ST Pipeline (https://github.com/jfnavarro/st_pipeline).

### License
MIT License, see LICENSE file.

### Authors
See AUTHORS file.

### Contact
For bugs, feedback or help you can contact Jose Fernandez Navarro <jc.fernandez.navarro@gmail.com>

### Input Format
The input format is a matrix of counts (tab delimited) where spot ids are row names
and the genes are column names. Additionally, some scripts may require a spot coordinates
file where the spot and pixel coordinates are defined for each spot id (tab delimited).

### Installation
Before you install the ST Analysis package we recommend that you create a Python 3 virtual
environment. We recommend [Anaconda](https://anaconda.org/anaconda/python).

The ST Analysis is only computatible with Python 3.

The following instructions are for installing the ST Analysis package with Python 3.6 and Anaconda

    git clone https://github.com/jfnavarro/st_analysis.git
    cd st_analysis
    python setup.py install

A set of scripts (described below) will then be available in your system or
the environment of choice if you chose to work on a specific environment.

Note that if you want to use `align_sections.py`you will have to install
the [st_tissue_recognition](https://github.com/jfnavarro/st_tissue_recognition) library.

Note that you can always type `script_name.py --help` to get more information
about how a script works and its parameters.

## Analysis tools

### Unsupervised clustering
To cluster spot together based on their expression profiles you can run:

    unsupervised.py --counts matrix_counts.tsv --normalization REL --num-clusters 5 --clustering KMeans --dimensionality tSNE --use-log-scale

The script can be given one or serveral datasets (matrices of counts).
The script allows for multiple normalization and filtering options.
The script will perform dimesionality reduction and then cluster the spot
together based on the manifold space.
The script implements multiple options for clustering and dimensionality reduction.
The script generates a scatter plot of the clustered spots in a 2D or 3D manifold.
The script will write the computed clusters/labels per spot in a file (tab delimited).

To know more about the parameters you can type --help

### Supervised classification
You can train a classifier with the expression profiles of a set of spots
where you know the class (cluster) and then predict the class of the spots
of a new dataset of the same tissue. For that you can use the following script:

    supervised.py --train-data data_matrix.tsv --test-data data_matrix.tsv --train-casses train_classes.txt --test-classes test_classes.txt

This will generate some statistics and a file with the predicted classes/clusters for each spot.
The script allows for several options for normalization and classification settings and algorithms.
The test/train classes file shoud look like:

    SPOT1 1
    SPOT2 1
    SPOT3 2

Where 1,1 and 2 are spot classes (clusters).

To know more about the parameters you can type --help

NOTE: there is a version that uses GPU and Neural Networks (supervised_torch.py)

### To visualize Spatial Transcriptomics (ST) datasets
Use the script data_plotter.py to visualize ST data, you can use different thresholds for
filtering and different normalization and visualization options.
The script allows to plot clusters as well as gene sets.
The script generates one image for each gene given in the --show-genes option (one sub-image for each input dataset).
The script needs one or more matrices of counts where the spots are rows and the genes are columns.

    data_plotter.py --cutoff 2 --show-genes Actb Apoe --counts data_matrix.tsv --normalization REL

This will generate a scatter plot of the expression of the spots that contain a gene Actb and with higher expression than 2.

More info if you type --help

### To filter a matrix of counts (keep or remove genes)

    filter_genes_matrix.py --counts data_matrix.tsv --filter-genes Malat1 Actb
    keep_genes_matrix.py --counts data_matrix.tsv --keep-genes Malat1 Actb

More info if you type --help

### To merge matrices of counts into one
An index corresponding to each matrix given in the input (same order) will be appended to the spot ids
of the merged matrix.

    merge_counts.py --counts data_matrix1.tsv data_matrix2.tsv

More info if you type --help

### To merge Spatial Transcriptomics datasets into one
This script will merge Spatial Transcriptomics datasets into one (matrices
of counts, spot coordinates and HE images). The matrices of counts will be
merged as in the previous script. The HE images will be stitched together
and the spoot coordinates will be merged together. An index corresponding
to each dataset will be appended to the spot ids.

    merge_datasets.py --counts data_matrix1.tsv data_matrix2.tsv --coordinates spots1.txt spots2.txt --images image1.jpg --images image2.jpg

More info if you type --help

### To align Spatial Transcriptomics datasets of the same tissue using the HE images
If you have multiple sections (dataset) of the same tissue you may want to align them
so they all have the same orienation and angle. This enables better visuaalizations.
The script `align_sections.py` takes as input a list of matrices of counts, spot coordinates
and HE images corresponding to the datasets that must be aligned. It will output a list of
aligned matrices of counts, aligned spot coordinates and aligned HE images. The script supports
different algorithms for the image detection and alignment process. The first dataset is used
as a reference.

    align_sections.py --counts data_matrix1.tsv data_matrix2.tsv --coordinates spots1.txt spots2.txt --images image1.jpg --images image2.jpg

More info if you type --help

### To visualize variables or genes on a manifold (dimensionality reduction) space
This script takes as input a list of matrices of counts and file with the reduced coordinates
of the spots (2D) and a meta-file (spots and variables). The script will generate a list of
scatter plots where each variable will be plotted onto the 2D manifold of the datasets. The script
can also plot the expression of genes if given as input. It allows to use different normalization,
filtering and visualization options.

    dimredu_plotter.py --counts data_matrix.tsv --dim-redu-file dimred.txt --meta-file meta.tsv --show-genes Actb Apoe

More info if you type --help

### To transform Visium datasets to the standard ST (Spatial Transcriptomics) format
This script will transformt a dataset in Visium format to the standard ST format (matrix of counts,
spot coordinates and HE image).

    visiumToST.py --help

### To transform old ST spot coordinates to new format (including pixel coordinates)

    convert_spot_coordinates.py --help

redpajama_set_name: RedPajamaGithub


text:
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/blktrans.h>
#include <linux/module.h>

static int mtdblock_readsect(struct mtd_blktrans_dev *dev,
			      unsigned long block, char *buf)
{
	size_t retlen;

	if (mtd_read(dev->mtd, (block * 512), 512, &retlen, buf))
		return 1;
	return 0;
}

static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
			      unsigned long block, char *buf)
{
	size_t retlen;

	if (mtd_write(dev->mtd, (block * 512), 512, &retlen, buf))
		return 1;
	return 0;
}

static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
{
	struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);

	if (!dev)
		return;

	dev->mtd = mtd;
	dev->devnum = mtd->index;

	dev->size = mtd->size >> 9;
	dev->tr = tr;
	dev->readonly = 1;

	if (add_mtd_blktrans_dev(dev))
		kfree(dev);
}

static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
{
	del_mtd_blktrans_dev(dev);
}

static struct mtd_blktrans_ops mtdblock_tr = {
	.name		= "mtdblock",
	.major		= 31,
	.part_bits	= 0,
	.blksize 	= 512,
	.readsect	= mtdblock_readsect,
	.writesect	= mtdblock_writesect,
	.add_mtd	= mtdblock_add_mtd,
	.remove_dev	= mtdblock_remove_dev,
	.owner		= THIS_MODULE,
};

static int __init mtdblock_init(void)
{
	return register_mtd_blktrans(&mtdblock_tr);
}

static void __exit mtdblock_exit(void)
{
	deregister_mtd_blktrans(&mtdblock_tr);
}

module_init(mtdblock_init);
module_exit(mtdblock_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
MODULE_DESCRIPTION("Simple read-only block device emulation access to MTD devices");


text:
<html>
<body>
<span style="font-family: verdana,serif;">
This inspection used when a class has no __init__ method, neither its parent classes.
</span>
</body>
</html>


text:
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var MongoStore = require('connect-mongo')(session);
var bodyParser = require('body-parser');
var multer = require('multer');

// MongoDBへの接続
import mongoose = require('mongoose');
(() => {
  mongoose.connect('mongodb://localhost/gspecv');
  var db = mongoose.connection;
  db.on('error', console.error.bind(console, 'connection error:'));
  db.once('open', function() {
    console.log('Connect to mongodb.');
  });
})();

import MM = require('./models/mongo_model');
var mongoModels = new MM.MongoModel(mongoose);

var constants = require('./models/constants.js');
var main_page = require('./routes/main_page').setup(mongoModels);
var login = require('./routes/login').setup(mongoModels);

var express = require('express');
var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, '../public')));
app.use(session({
  secret: 'secret_value', ///< @todo 環境変数から読み込む
  resave: false,
  saveUninitialized: true,
  store: new MongoStore({
    db: 'gspecv',
    host: 'localhost',
    clear_interval: 60 * 60 * 24 * 7  // 1週間保存
  }),
  cookie: {
    httpOnly: false,
    maxAge: new Date(Date.now() + 60 * 60 * 24 * 7 * 1000)
  }
}));

// アップロードされたファイルの保存先を設定
app.use(multer({ dest: constants.FILE_UPLOAD_DIRECTORY }));

app.use('/', main_page);
app.use('/login', login);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
    var err = new Error('Not Found');
    (<any>err).status = 404;
    next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
        res.status(err.status || 500);
        res.render('error', {
            message: err.message,
            error: err
        });
    });
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
        message: err.message,
        error: {}
    });
});

module.exports = app;


text:
<?php

namespace Blog\ModelBundle\DataFixtures\ORM;

use Blog\ModelBundle\Entity\Comment;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;

/**
 * Loads comments fixtures
 */
class Comments extends AbstractFixture implements OrderedFixtureInterface
{
    /**
     * {@inheritDoc}
     */
    public function getOrder()
    {
        return 20;
    }

    /**
     * {@inheritDoc}
     */
    public function load(ObjectManager $manager)
    {
        $posts = $manager->getRepository('ModelBundle:Post')->findAll();

        $comments = [
          0 => 'Suspendisse quis nulla ut lectus fringilla porta in eget sapien. Cras imperdiet sodales consectetur. Sed suscipit efficitur velit eu ultricies. Vestibulum sit amet purus iaculis, dignissim eros vel, fringilla nisi. Maecenas sed dui in enim consectetur consectetur at ac dolor. Sed ac massa leo. Morbi dignissim eleifend orci, at iaculis diam gravida vitae. Proin sed turpis quam. Aliquam commodo quis leo ut pretium. Quisque ornare arcu id dolor imperdiet, ac pharetra diam suscipit. Ut nec consectetur felis. Proin tempor convallis nisi nec iaculis. Morbi tristique sapien metus, ornare ullamcorper orci tempor ut. Morbi faucibus, diam in interdum sagittis, ante sapien varius ipsum, molestie cursus dolor enim id sem. Donec bibendum mauris at neque malesuada, non ornare mauris placerat. ',
          1 => 'Vestibulum augue ipsum, ultricies ut turpis ut, facilisis vulputate sem. Maecenas vitae est ultricies, porta metus nec, auctor nisl. Proin non dui at mi ultricies congue. Duis malesuada tincidunt vulputate. Duis ultrices nulla velit, at tristique eros pharetra et. Aliquam at sapien in tortor sodales vehicula. Vestibulum ut erat orci. Pellentesque nunc dui, posuere sit amet massa sed, eleifend pulvinar ligula. Suspendisse id odio purus. Sed placerat lacus mattis turpis sodales mattis. Duis at massa pretium, blandit purus in, euismod quam. Sed quis rhoncus ante. Integer non suscipit purus. ',
          2 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis gravida consectetur ipsum vel rutrum. Duis non consectetur purus. Maecenas elementum volutpat leo et venenatis. Sed consectetur augue vitae metus vestibulum fringilla. Integer faucibus tellus sit amet erat posuere tincidunt. Cras faucibus a augue ac dapibus. Maecenas ut dolor sit amet augue sagittis sagittis ac sed nisi. Morbi in felis sit amet nibh pharetra vehicula. Donec in cursus augue. '
          ];

        $i = 0;

        foreach ($posts as $post)
        {
            $comment = new Comment();
            $comment->setAuthorName('Millard');
            $comment->setBody($comments[$i++]);
            $comment->setPost($post);

            $manager->persist($comment);
        }

        $manager->flush();
    }
}


text:
package hub

import (
	"github.com/utrack/go-simple-chat/client"
	"github.com/utrack/go-simple-chat/message"
)

// session is a middleware between a client
// and the hub.
//
// session forwards messages and discon notifications
// from a client to the hub's main chan.
type session struct {
	// underlying client
	c client.Client

	// client's name
	name string

	// hub's main incoming messages' channel
	chatChannelChan chan<- message.One

	disconChan chan<- disconMsg
}

// newSession returns a forged session for given
// client.
// args: client, its name, channel to dump incoming messages to.
func newSession(c client.Client, name string, ch chan<- message.One, dch chan<- disconMsg) *session {
	return &session{
		c:               c,
		name:            name,
		chatChannelChan: ch,
		disconChan:      dch,
	}
}

func (s *session) runPump() {
	incoming := s.c.MsgChan()
	discon := s.c.DisconChan()
	for {
		select {
		case msg := <-incoming:
			// Filter out malicious EventTypes
			switch msg.Type {
			case message.EventMessage:
			case message.EventPresenceState:
			default:
				continue
			}

			msg.From = s.name
			s.chatChannelChan <- msg
		case disconReason := <-discon:
			// Send Leaving... message
			s.chatChannelChan <- message.One{
				Type: message.EventLeave,
				From: s.name,
				Text: disconReason.Error(),
			}
			s.disconChan <- disconMsg{name: s.name, reason: disconReason.Error()}
			break
		}
	}
}

func (s *session) send(m message.One) error {
	return s.c.Send(m)
}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="8dp" >

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/chart_layout"
        android:text="TEXT1"
        android:textSize="16sp" />

    <TextView
        android:id="@+id/text2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/text1"
        android:layout_below="@+id/text1"
        android:layout_toLeftOf="@id/chart_layout"
        android:text="TEXT2"
        android:textSize="12sp" />

    <FrameLayout
        android:id="@id/chart_layout"
        android:layout_width="54dp"
        android:layout_height="54dp"
        android:layout_alignParentRight="true"
        android:visibility="gone" >
    </FrameLayout>

</RelativeLayout>


text:
{% extends 'base/base.html' %}

{% block content %}
{% endblock %}


text:
<?php
/**
 * This is a Loom pagecontroller.
 *
 */
// Include the essential config-file which also creates the $loom variable with its defaults.
include(__DIR__.'/config.php');

// Do it and store it all in variables in the Loom container.

// Add style for movie_db
$loom['stylesheets'][] = 'css/rm-calendar.css';
$loom['stylesheets'][] = 'css/rm-movie.css';

// Connect to a MySQL database using PHP PDO
$db = new CDatabase($loom['database']);

$loom['title'] = "Månadens film";
$out = "";

// Get html-output for calender
// If month is null show todays month
$date = isset($_GET['date']) ? $_GET['date'] : null;
$out .= CRMCalendar::output($db, $date);

// Do it and store it all in variables in the Loom container.
$loom['main'] = <<<EOD
$out
EOD;
// <h1>{$loom['title']}</h1>

// Finally, leave it all to the rendering phase of Loom.
include(LOOM_THEME_PATH);


text:
FROM karalabe/xgo-base

MAINTAINER Péter Szilágyi <peterke@gmail.com>

# Configure the root Go distribution and bootstrap based on it
ENV GO_VERSION 162

RUN \
  export ROOT_DIST=https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz     && \
  export ROOT_DIST_SHA=e40c36ae71756198478624ed1bb4ce17597b3c19d243f3f0899bb5740d56212a && \
  \
  $BOOTSTRAP_PURE


text:
<?php

namespace Oro\Bundle\ImportExportBundle\Tests\Unit\Formatter;

use Symfony\Component\Translation\Translator;

use Oro\Bundle\LocaleBundle\Model\LocaleSettings;
use Oro\Bundle\ImportExportBundle\Exception\InvalidArgumentException;
use Oro\Bundle\ImportExportBundle\Formatter\DateTimeTypeFormatter;

class DateTimeTypeFormatterTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var DateTimeTypeFormatter
     */
    protected $formatter;

    public function setUp()
    {
        /** @var LocaleSettings|\PHPUnit_Framework_MockObject_MockObject $localeSettings */
        $localeSettings = $this->getMockBuilder('Oro\Bundle\LocaleBundle\Model\LocaleSettings')
            ->disableOriginalConstructor()
            ->getMock();
        /** @var Translator|\PHPUnit_Framework_MockObject_MockObject $translator */
        $translator      = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Translation\Translator')
            ->disableOriginalConstructor()
            ->getMock();
        $this->formatter = new DateTimeTypeFormatter($localeSettings, $translator);
    }

    /**
     * @dataProvider testFormatTypeProvider
     * @param string          $value
     * @param string          $type
     * @param \Exception|null $exception
     */
    public function testFormatType($value, $type, \Exception $exception = null)
    {
        if (null !== $exception) {
            $this->setExpectedException(get_class($exception), $exception->getMessage());
        }
        $this->formatter->formatType($value, $type);
    }

    /**
     * @return array
     */
    public function testFormatTypeProvider()
    {
        $value = (new \DateTime())->format('d/m/Y H:i:s');

        return [
            'type datetime'           => [$value, DateTimeTypeFormatter::TYPE_DATETIME],
            'type date'               => [$value, DateTimeTypeFormatter::TYPE_DATETIME],
            'type time'               => [$value, DateTimeTypeFormatter::TYPE_DATETIME],
            'type not supported type' => [
                $value,
                'test',
                new InvalidArgumentException('Couldn\'t format "test" type')
            ],
        ];
    }
}


text:
package com.njyb.gbdbase.service.contrastreport.contrast;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.njyb.gbdbase.model.contrastreport.querybean.CommonSearchModel;
import com.njyb.gbdbase.model.datasearch.common.DataReportSumModel;
/**
 * 所有对比service
 * @author 章华才
 */
public interface ICompareService{

	/**
	 * 新增进出口商
	 * @param request
	 * @param field	             查询lucenc用到的字段名称
	 * @param values    查询字段的值
	 * @param model		查询用到的查询bean
	 * @param sortKey	排序字段
	 * @return list<T>
	 */
	public <T> List<DataReportSumModel> addImportAndExport(HttpServletRequest request,String [] field,String [] values,
			                         CommonSearchModel model,String sortKey,String countryName,String isAdd,String imexType);

	/**
	 * 保持进出口商
	 * @param request
	 * @param field	             查询lucenc用到的字段名称
	 * @param values    查询字段的值
	 * @param model		查询用到的查询bean
	 * @param sortKey	排序字段
	 * @return list<T>
	 */
	public <T> Map<String,DataReportSumModel> keepImporterAndExporter(HttpServletRequest request,String [] field,String [] values,
            						CommonSearchModel model,String sortKey,String countryName,String isAdd,String imexType);

	/**
	 * 流失进出口商
	 * @param request
	 * @param field	             查询lucenc用到的字段名称
	 * @param values    查询字段的值
	 * @param model		查询用到的查询bean
	 * @param sortKey	排序字段
	 * @return list<T>
	 */
	public <T> List<DataReportSumModel> outflowImportAndExport(HttpServletRequest request,String [] field,String [] values,
						CommonSearchModel model,String sortKey,String countryName,String isAdd,String imexType);
}


text:
#ifndef GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H
#define GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H

#include "src/core/iomgr/wakeup_fd_posix.h"

extern grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable;

#endif  /* GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H */


text:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

// 从 Chord 项目复制代码而来

namespace DigitalPlatform.MessageClient
{
    /// <summary>
    /// 广播式检索结果的管理器
    /// 能判断出响应的数据是否已经完全到来
    /// </summary>
    public class ResultManager
    {
        public long _targetCount = -1;  // -1 表示目标对象数量未知

        Hashtable _targetTable = new Hashtable();   // target id --> HitInfo

        // return:
        //      false   响应还没有完全到来
        //      true    响应已经完全到来
        public bool SetTargetCount(long count)
        {
            _targetCount = count;
            return IsAllCompleted();
        }

        public long GetTotalCount()
        {
            // TODO: 如果 -targetCount 为 -1,此时就无法探测准确的总数。不准确的可以作为负数返回?
            long count = 0;
            foreach (string targetid in _targetTable.Keys)
            {
                HitInfo info = _targetTable[targetid] as HitInfo;
                if (info.TotalResults >= 1)
                    count += Math.Max(info.Recieved, info.TotalResults);    // 有时候弄错了 libraryUID 的情况下,可能都归到一个对象,导致 recieved 数字大于 totalResults 数字
            }

            return count;
        }

        public bool IsAllCompleted()
        {
            if (_targetCount == -1)
                return false;   // 暂时无法判断

            int complete_count = 0; // 已经完成的对象个数
#if NO
            bool bOverflow = false; // 是否有 recieved > totalResults 的情况
            long total_count = 0;   // 总命中的记录数累计
            long recieve_count = 0; // 收到的记录数累计
#endif
            foreach (string targetid in _targetTable.Keys)
            {
                HitInfo info = _targetTable[targetid] as HitInfo;

#if NO
                if (info.TotalResults > 0)
                    total_count += info.TotalResults;
                recieve_count += info.Recieved;

                if (info.TotalResults >= 1 && info.Recieved > info.TotalResults)
                    bOverflow = true;
#endif

                if (info.Recieved >= info.TotalResults)
                    complete_count++;

            }

            // 第一种判断法
            if (complete_count >= _targetCount)
                return true;

#if NO
            // 第二种判断法
            if (bOverflow == true && recieve_count >= total_count)
                return true;
#endif

            return false;
        }

        // 标记结束一个检索目标
        // return:
        //      0   尚未结束
        //      1   结束
        //      2   全部结束
        public int CompleteTarget(string strLibraryUID, long total_count, long this_count)
        {
            HitInfo info = _targetTable[strLibraryUID] as HitInfo;
            if (info == null)
            {
                info = new HitInfo();
                info.TotalResults = total_count;
                _targetTable[strLibraryUID] = info;
            }
            info.Recieved += this_count;
            Debug.WriteLine(strLibraryUID + "\r\n" + info.Dump());
            if (info.Recieved >= info.TotalResults)
            {
                if (IsAllCompleted())
                    return 2;
                return 1;
            }
            return 0;
        }

    }

    // 一次检索命中的信息
    public class HitInfo
    {
        public long TotalResults = 0;   // 总的命中数量。-1 表示已出错
        public long Recieved = 0;   // 已经收到的数量

        public string Dump()
        {
            StringBuilder text = new StringBuilder();
            text.Append("TotalResults=" + this.TotalResults + "\r\n");
            text.Append("Recieved=" + this.Recieved + "\r\n");
            return text.ToString();
        }
    }

}


text:
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Neemo.CarParts.EntityFramework.Models.Mapping
{
    public class PartFeatureMap : EntityTypeConfiguration<PartFeature>
    {
        public PartFeatureMap()
        {
            // Primary Key
            this.HasKey(t => t.PartFeatureID);

            // Properties
            this.Property(t => t.Image)
                .HasMaxLength(100);

            this.Property(t => t.CreatedByUser)
                .HasMaxLength(50);

            this.Property(t => t.LastModifiedByUser)
                .HasMaxLength(50);

            this.Property(t => t.DeletedByUser)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("PartFeature");
            this.Property(t => t.PartFeatureID).HasColumnName("PartFeatureID");
            this.Property(t => t.PartID).HasColumnName("PartID");
            this.Property(t => t.FeatureID).HasColumnName("FeatureID");
            this.Property(t => t.Image).HasColumnName("Image");
            this.Property(t => t.Active).HasColumnName("Active");
            this.Property(t => t.CreatedDateTime).HasColumnName("CreatedDateTime");
            this.Property(t => t.CreatedByUser).HasColumnName("CreatedByUser");
            this.Property(t => t.LastModifiedDateTime).HasColumnName("LastModifiedDateTime");
            this.Property(t => t.LastModifiedByUser).HasColumnName("LastModifiedByUser");
            this.Property(t => t.DeletedDateTime).HasColumnName("DeletedDateTime");
            this.Property(t => t.DeletedByUser).HasColumnName("DeletedByUser");
            this.Property(t => t.EffectiveDateFrom).HasColumnName("EffectiveDateFrom");
            this.Property(t => t.EffectiveDateTo).HasColumnName("EffectiveDateTo");

            // Relationships
            this.HasRequired(t => t.Part)
                .WithMany(t => t.PartFeatures)
                .HasForeignKey(d => d.PartID);

        }
    }
}


text:
package com.rimerosolutions.ant.git;

import org.eclipse.jgit.lib.ProgressMonitor;

/**
 * Basic Task execution monitor.
 *
 * @author Yves Zoundi
 */
public class GitTaskMonitor implements ProgressMonitor {

        public static final String MESSAGE_STARTING = "starting";
        public static final String MESSAGE_BEGIN = "begin";
        public static final String MESSAGE_STATUS = "status";
        public static final String MESSAGE_ENDING = "ending";
        private final GitTask task;
        private int totalTasks;

        public GitTaskMonitor(GitTask task) {
                this.task = task;
        }

        @Override
        public void start(int totalTasks) {
                this.totalTasks = totalTasks;
                task.log(String.format("[%s] %s", task.getName(), MESSAGE_STARTING));
        }

        @Override
        public void beginTask(String title, int totalWork) {
                task.log(String.format("[%s] %s", title, MESSAGE_BEGIN));
        }

        @Override
        public void update(int completed) {
                task.log(String.format("[%s] %s [%d/%d]", task.getName(), MESSAGE_STATUS, completed, totalTasks));
        }

        @Override
        public boolean isCancelled() {
                return false;
        }

        @Override
        public void endTask() {
                task.log(String.format("[%s] %s", task.getName(), MESSAGE_ENDING));
        }

}


text:
require 'google/protobuf'

require 'google/api/annotations_pb'
require 'google/api/client_pb'
require 'google/api/field_behavior_pb'
require 'google/api/resource_pb'
require 'google/protobuf/empty_pb'
require 'google/protobuf/field_mask_pb'

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_file("google/cloud/dialogflow/cx/v3/security_settings.proto", :syntax => :proto3) do
    add_message "google.cloud.dialogflow.cx.v3.GetSecuritySettingsRequest" do
      optional :name, :string, 1
    end
    add_message "google.cloud.dialogflow.cx.v3.UpdateSecuritySettingsRequest" do
      optional :security_settings, :message, 1, "google.cloud.dialogflow.cx.v3.SecuritySettings"
      optional :update_mask, :message, 2, "google.protobuf.FieldMask"
    end
    add_message "google.cloud.dialogflow.cx.v3.ListSecuritySettingsRequest" do
      optional :parent, :string, 1
      optional :page_size, :int32, 2
      optional :page_token, :string, 3
    end
    add_message "google.cloud.dialogflow.cx.v3.ListSecuritySettingsResponse" do
      repeated :security_settings, :message, 1, "google.cloud.dialogflow.cx.v3.SecuritySettings"
      optional :next_page_token, :string, 2
    end
    add_message "google.cloud.dialogflow.cx.v3.CreateSecuritySettingsRequest" do
      optional :parent, :string, 1
      optional :security_settings, :message, 2, "google.cloud.dialogflow.cx.v3.SecuritySettings"
    end
    add_message "google.cloud.dialogflow.cx.v3.DeleteSecuritySettingsRequest" do
      optional :name, :string, 1
    end
    add_message "google.cloud.dialogflow.cx.v3.SecuritySettings" do
      optional :name, :string, 1
      optional :display_name, :string, 2
      optional :redaction_strategy, :enum, 3, "google.cloud.dialogflow.cx.v3.SecuritySettings.RedactionStrategy"
      optional :redaction_scope, :enum, 4, "google.cloud.dialogflow.cx.v3.SecuritySettings.RedactionScope"
      optional :inspect_template, :string, 9
      optional :deidentify_template, :string, 17
      repeated :purge_data_types, :enum, 8, "google.cloud.dialogflow.cx.v3.SecuritySettings.PurgeDataType"
      optional :audio_export_settings, :message, 12, "google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings"
      optional :insights_export_settings, :message, 13, "google.cloud.dialogflow.cx.v3.SecuritySettings.InsightsExportSettings"
      oneof :data_retention do
        optional :retention_window_days, :int32, 6
      end
    end
    add_message "google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings" do
      optional :gcs_bucket, :string, 1
      optional :audio_export_pattern, :string, 2
      optional :enable_audio_redaction, :bool, 3
      optional :audio_format, :enum, 4, "google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings.AudioFormat"
    end
    add_enum "google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings.AudioFormat" do
      value :AUDIO_FORMAT_UNSPECIFIED, 0
      value :MULAW, 1
      value :MP3, 2
      value :OGG, 3
    end
    add_message "google.cloud.dialogflow.cx.v3.SecuritySettings.InsightsExportSettings" do
      optional :enable_insights_export, :bool, 1
    end
    add_enum "google.cloud.dialogflow.cx.v3.SecuritySettings.RedactionStrategy" do
      value :REDACTION_STRATEGY_UNSPECIFIED, 0
      value :REDACT_WITH_SERVICE, 1
    end
    add_enum "google.cloud.dialogflow.cx.v3.SecuritySettings.RedactionScope" do
      value :REDACTION_SCOPE_UNSPECIFIED, 0
      value :REDACT_DISK_STORAGE, 2
    end
    add_enum "google.cloud.dialogflow.cx.v3.SecuritySettings.PurgeDataType" do
      value :PURGE_DATA_TYPE_UNSPECIFIED, 0
      value :DIALOGFLOW_HISTORY, 1
    end
  end
end

module Google
  module Cloud
    module Dialogflow
      module CX
        module V3
          GetSecuritySettingsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.GetSecuritySettingsRequest").msgclass
          UpdateSecuritySettingsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.UpdateSecuritySettingsRequest").msgclass
          ListSecuritySettingsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.ListSecuritySettingsRequest").msgclass
          ListSecuritySettingsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.ListSecuritySettingsResponse").msgclass
          CreateSecuritySettingsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.CreateSecuritySettingsRequest").msgclass
          DeleteSecuritySettingsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.DeleteSecuritySettingsRequest").msgclass
          SecuritySettings = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.SecuritySettings").msgclass
          SecuritySettings::AudioExportSettings = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings").msgclass
          SecuritySettings::AudioExportSettings::AudioFormat = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.SecuritySettings.AudioExportSettings.AudioFormat").enummodule
          SecuritySettings::InsightsExportSettings = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.SecuritySettings.InsightsExportSettings").msgclass
          SecuritySettings::RedactionStrategy = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.SecuritySettings.RedactionStrategy").enummodule
          SecuritySettings::RedactionScope = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.SecuritySettings.RedactionScope").enummodule
          SecuritySettings::PurgeDataType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.dialogflow.cx.v3.SecuritySettings.PurgeDataType").enummodule
        end
      end
    end
  end
end


text:
package com.baidubce.services.cdn.model.domain;

import com.baidubce.services.cdn.model.CdnRequest;

/**
 * create by changxing01 on 19/8/27
 */
public class SetDomainFollowProtocolRequest extends CdnRequest {
    private String domain;
    private boolean followProtocol;

    /**
     * @return followProtocol
     */
    public boolean isFollowProtocol() {
        return followProtocol;
    }

    /**
     * @param followProtocol Whether the back source protocol is consistent with the request protocol
     */
    public void setFollowProtocol(boolean followProtocol) {
        this.followProtocol = followProtocol;
    }

    /**
     * @param followProtocol Whether the back source protocol is consistent with the request protocol
     * @return this object
     */
    public SetDomainFollowProtocolRequest withFollowProtocol(boolean followProtocol) {
        this.followProtocol = followProtocol;
        return this;
    }

    /**
     * @return domain
     */
    public String getDomain() {
        return domain;
    }

    /**
     * @param domain the domain name
     */
    public void setDomain(String domain) {
        this.domain = domain;
    }

    /**
     * @param domain the domain name
     * @return returns this object
     */
    public SetDomainFollowProtocolRequest withDomain(String domain) {
        this.domain = domain;
        return this;
    }
}


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

<TITLE>
Uses of Class implementation.gridpuzzle.GridState
</TITLE>

<META NAME="date" CONTENT="2010-11-13">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Uses of Class
implementation.gridpuzzle.GridState

Packages that use GridState

implementation.gridpuzzle

Uses of GridState in implementation.gridpuzzle

Methods in implementation.gridpuzzle that return GridState

 GridState
GridState.getParent()

 GridState
GridProblem.initial()

Methods in implementation.gridpuzzle that return types with arguments of type GridState

 java.util.List<GridState>
GridProblem.expand(GridState state)

Methods in implementation.gridpuzzle with parameters of type GridState

 int
GridProblem.depth(GridState state)

 boolean
GridState.equals(GridState g)

 java.util.List<GridState>
GridProblem.expand(GridState state)

 double
GridProblem.g(GridState state)

 double
GridProblem.h(GridState state)

 boolean
GridProblem.isGoal(GridState state)

Constructors in implementation.gridpuzzle with parameters of type GridState

GridState(GameGrid current,
          java.awt.Point move,
          GridState parent)

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes


text:
package com.google.javascript.rhino.jstype;

/**
 * Bottom type, representing the subclass of any value or object.
 *
 * Although JavaScript programmers can't explicitly denote the bottom type,
 * it comes up in static analysis. For example, if we have:
 *
 * var x = null;
 * if (x) {
 *   f(x);
 * }
 *
 * We need to be able to assign {@code x} a type within the {@code f(x)}
 * call. Since it has no possible type, we assign {@code x} the NoType,
 * so that {@code f(x)} is legal no matter what the type of {@code f}'s
 * first argument is.
 *
 * @see Bottom types
 */
public class NoType extends NoObjectType {
  private static final long serialVersionUID = 1L;

  NoType(JSTypeRegistry registry) {
    super(registry);
  }

  @Override
  public boolean isNoObjectType() {
    return false;
  }

  @Override
  public boolean isNoType() {
    return true;
  }

  @Override
  public boolean isNullable() {
    return true;
  }

  @Override
  public boolean isSubtype(JSType that) {
    return true;
  }

  @Override
  public BooleanLiteralSet getPossibleToBooleanOutcomes() {
    return BooleanLiteralSet.EMPTY;
  }

  @Override
  public boolean matchesNumberContext() {
    return true;
  }

  @Override
  public boolean matchesObjectContext() {
    return true;
  }

  @Override
  public boolean matchesStringContext() {
    return true;
  }

  @Override
  public <T> T visit(Visitor<T> visitor) {
    return visitor.caseNoType();
  }

  @Override
  String toStringHelper(boolean forAnnotations) {
    return forAnnotations ? "?" : "None";
  }
}


text:
var _ = require('underscore');
exports.type = "array";
exports.transform = function(values){
  var total = (typeof _.first(values) === 'number') ? 0 : "";
  if (!values.forEach){
    return;
  }
  values.forEach(function(value){
    if (typeof value === 'number' || typeof value === 'string'){
      total += value;
    }
  });
  return total;
};


text:
/**
 * etch_cache.h -- etch cache methods.
 */

#include "etch_cache.h"
#include "etch_hash.h"

#define ETCH_CACHE_USES_ALPHA_KEY
#define ETCH_CACHE_DEBUG FALSE
#define ETCH_CACHE_INITIAL_SIZE 32
#define ETCH_CACHE_KEYBUFLEN 20

etch_cache_t* g_etch_cache = NULL;
etch_mutex* g_etch_cache_mutex = NULL;

/*
 * ETCH_CACHE_USES_ALPHA_KEY switches on alpha cache keys rather than the normal
 * 4-byte integer. experiencing a problem with either the hfirst or hnext
 * hashtable functionality, this was an attempt to determine if the 4-byte keys
 * were causing the problem. it appears not, so we can probably use int keys again.
 */
#ifdef ETCH_CACHE_USES_ALPHA_KEY

char ckey[ETCH_CACHE_KEYBUFLEN];

/*
 * make_cache_key()
 * given 32-bit key constructs alpha key for the cache returning key byte length
 */
static int etch_make_cache_key(const unsigned int ikey)
{
   char* pkey = ckey;
   sprintf(pkey,"%d", ikey);
   return (int)strlen(ckey);
}

/*
 * etch_cache_populate_out()
 * populate caller's out struct
 */
static void etch_cache_populate_out(etch_hashitem* useritem, etch_hashitem* curritem)
{
    useritem->key   = curritem->key;
    useritem->value = curritem->value;
    useritem->hash  = curritem->hash;
}

/*
 * cache_findxl()
 */
void* etch_cache_findxl(char* key, unsigned keylen, void** out)
{
    etch_hashitem  hashbucket;
    etch_hashitem* founditem = &hashbucket;

    int result = jenkins_find
      (g_etch_cache->realtable, key, keylen, 0, (void**)&founditem);

    #if ETCH_CACHE_DEBUG
    #pragma warning(disable:4313)
    if  (result == 0)
         printf("cache_found key %s len %d addr %08x\n",
                 key, keylen, founditem->value);
    else printf("cache_notfound key %s len %d\n", key, keylen);
    #endif

    if (result == -1) return NULL;

    if (out)
        etch_cache_populate_out(*out, founditem);

    return founditem->value;
}

/*
 * cache_find()
 * locate cached object with specified key, returning it or NULL
 */
void* etch_cache_find(const unsigned int objtype, void** out)
{
    unsigned keylen = 0;
    void* res = NULL;
    etch_mutex_lock(g_etch_cache_mutex);
    keylen = etch_make_cache_key(objtype);
    res = etch_cache_findxl(ckey, keylen, out);
    etch_mutex_unlock(g_etch_cache_mutex);
    return res;
}

/*
 * cache_findx()
 * locate cached object with specified ansi char key, returning it or NULL
 */
void* etch_cache_findx(char* key, void** out)
{
    unsigned keylen = (unsigned)strlen(key);

    return etch_cache_findxl(key, keylen, out);
}

/*
 * cache_find_by_hash()
 * locate cached object with specified hashkey, returning it or NULL
 */
void* etch_cache_find_by_hash(const unsigned hash, void** out)
{
    int result;
    etch_hashitem  hashbucket;
    etch_hashitem* founditem = &hashbucket;

    result = jenkins_findh(g_etch_cache->realtable, hash, 0, (void**)&founditem);

    if (result == -1) return NULL;

    if (out)
        etch_cache_populate_out(*out, founditem);

    return founditem->value;
}

/*
 * cache_current()
 * return cached object at current position
 */
etch_hashitem* etch_cache_current()
{
    int result;
    etch_hashitem  hashbucket;
    etch_hashitem* founditem = &hashbucket;

    result = jenkins_current(g_etch_cache->realtable, 0, (void**)&founditem);

    return (result == -1)? NULL: founditem;
}

/*
 * cache_delxl()
 * Remove specified object from cache given ansi char key and length.
 * Return pointer to cached object, which is not freed here.
 */
void* etch_cache_delxl(char* key, const unsigned keylen)
{
    etch_hashitem hashbucket;
    etch_hashitem* founditem = &hashbucket;

    int result = jenkins_remove
      (g_etch_cache->realtable, ckey, keylen, 0, (void**)&founditem);

    if (result == -1) return NULL;
    free(founditem->key); /* free 4-byte key allocated in cache_add() */
    return founditem->value;
}

/*
 * cache_del()
 * Remove specified object from cache given integer key.
 * Return pointer to cached object, which is not freed here.
 */
void* etch_cache_del(const unsigned int objtype)
{
    unsigned keylen = 0;
    void* res = NULL;

    etch_mutex_lock(g_etch_cache_mutex);
    keylen = etch_make_cache_key(objtype);
    res = etch_cache_delxl(ckey, keylen);
    etch_mutex_unlock(g_etch_cache_mutex);
    return res;
}

/*
 * cache_delx()
 * Remove specified object from cache given ansi char key.
 * Return pointer to cached object, which is not freed here.
 */
void* etch_cache_delx (char* key)
{
    unsigned keylen = (unsigned)strlen(key);

    return etch_cache_delxl(key, keylen);
}

/*
 * cache_insertxl()
 * Add specified object to cache given ansi char key and char length,
 * with existence test optional.
 * Return hash of supplied key, or zero.
 */
int etch_cache_insertxl (char* key, const unsigned keylen, void* data, const int is_check)
{
    int   result = 0, keylent = 0;
    char* pkey = NULL;
    void* pval = NULL;
    etch_hashitem  hashbucket;
    etch_hashitem* inserteditem = &hashbucket;
    memset(&hashbucket, 0, sizeof(etch_hashitem));

    if (is_check)
      {   pval = etch_cache_findxl(key, keylen, (void**)&inserteditem);
        if (pval) return inserteditem->hash; /* entry exists */
    }

    keylent = keylen + 1;/* add new entry */
    pkey    = etch_malloc(keylent, 0);
	strcpy(pkey, key);

    #if CACHE_DEBUG
    #pragma warning(disable:4313)
    printf("cache_insertxl key %s len %d addr %08x\n", pkey, keylen, data);
    #endif

    result = jenkins_insert
      (g_etch_cache->realtable, pkey, keylen, data, 0, 0, (void**)&inserteditem);

    /* cache_dump(); */

    return inserteditem->hash;
}

/*
 * cache_insert()
 * Add specified object to cache with existence test optional.
 * Return inserted item hash, or zero.
 */
int etch_cache_insert (const unsigned int key, void* data, const int is_check)
{
    int keylen = 0;
    int res = 0;
    etch_mutex_lock(g_etch_cache_mutex);
    keylen = etch_make_cache_key(key);
    res = etch_cache_insertxl(ckey, keylen, data, is_check);
    etch_mutex_unlock(g_etch_cache_mutex);
    return res;
}

/*
 * cache_insertx()
 * Add specified object to cache with existence test optional.
 * Return inserted item hash, or zero.
 */
int etch_cache_insertx (char* key, void* data, const int is_check)
{
    unsigned keylen = (unsigned)strlen(key);

    return etch_cache_insertxl(key, keylen, data, is_check);
}

/*
 * cache_add()
 * Add specified object to cache given integer key.
 * Return 0 or -1.
 */
int etch_cache_add(const unsigned int objtype, void* data)
{
    return etch_cache_insert (objtype, data, TRUE);
}

/*
 * cache_addx()
 * Add specified object to cache.
 * Return 0 or -1.
 */
int etch_cache_addx(char* key, void* data)
{
    return etch_cache_insertx(key, data, TRUE);
}

#else // #ifdef ETCH_CACHE_USES_ALPHA_KEY

/*
 * cache_find()
 * locate cached object with specified key, returning it or NULL
 */
void* etch_cache_find(const unsigned int objtype)
{
    etch_hashitem hashbucket;
    etch_hashitem* founditem = &hashbucket;
    int result = jenkins_find
       (g_etch_cache->realtable, (char*)&objtype, sizeof(int), 0, &founditem);
    return result == -1? NULL: founditem->value;
}

/*
 * cache_del()
 * Remove specified object from cache.
 * Return pointer to cached object, which is not freed here.
 */
void* etch_cache_del (const unsigned int objtype)
{
    etch_hashitem hashbucket;
    etch_hashitem* founditem = &hashbucket;
    int result = jenkins_remove
       (g_etch_cache->realtable, (char*)&objtype, sizeof(int), 0, &founditem);
    if (result == -1) return NULL;
    free(founditem->key); /* free 4-byte key allocated in cache_add() */
    return founditem->value;
}

*
 * cache_add()
 * Add specified object to cache.
 * Return pointer to item's data entry, which is not freed here.
 */
int etch_cache_add (const unsigned int objtype, void* data)
{
    int result = 0;
    char* pkey = 0;
    void* pval = cache_find(objtype);
    if (pval) return 0; /* entry exists */

    pkey = etch_malloc(sizeof(int), 0); /* add new entry */
    memcpy(pkey, &objtype, sizeof(int));

    result = jenkins_insert
       (g_etch_cache->realtable, pkey, sizeof(int), data, 0, 0, 0);
    return result;
}

#endif // #ifdef ETCH_CACHE_USES_ALPHA_KEY

int etch_cache_freehook(void* key, void* value)
{
    etch_free(key);
    etch_object_destroy((vtabmask*)value);

    return 1;
}

/*
 * cache_create()
 * create the global cache as an untracked hashtable
 */
etch_status_t etch_cache_create()
{
    etch_status_t etch_status = ETCH_SUCCESS;

    assert(g_etch_cache == NULL);

    etch_status = etch_mutex_create(&g_etch_cache_mutex, ETCH_MUTEX_NESTED, NULL);
    if(etch_status != ETCH_SUCCESS) {
        // error
        return etch_status;
    }
    g_etch_cache = new_systemhashtable(ETCH_CACHE_INITIAL_SIZE);
    g_etch_cache->freehook = etch_cache_freehook;

    return etch_status;
}

etch_status_t etch_cache_set_freehook(etch_cache_freehook_func freehook)
{
    etch_status_t rv = ETCH_SUCCESS;
    g_etch_cache->freehook = freehook;
    return rv;
}

/*
 * cache_clear()
 * remove all objects from the runtime list, freeing both key memory and
 * data object memory for each. Returns the count of buckets so cleared.
 */
int etch_cache_clear()
{
    int result = jenkins_clear(g_etch_cache->realtable, TRUE, TRUE, g_etch_cache, 0);
    return result;
}

/*
 * cache_destroy()
 * clear the cache and destroy the cache object
 */
int etch_cache_destroy()
{
    int result = etch_cache_clear();
    result = jenkins_destroy(g_etch_cache->realtable, 0, 0);
    etch_free(g_etch_cache);
    g_etch_cache = NULL;
    etch_object_destroy(g_etch_cache_mutex);
    g_etch_cache_mutex = NULL;
    return result;
}

/*
 * cache_count()
 * return number of items in the runtime cache
 */
int etch_cache_count()
{
    return jenkins_count(g_etch_cache->realtable, 0, 0);
}


text:
published: true
layout: post
title: "Cours et TD du vendredi 9 octobre 2015"
category: cahier_de_texte
---
Réponses aux questions apparues pendant la séance précédente pendant la résolution de l'exercice sur la cohérence spatiale (voir post précédent).

Suite du cours sur les interférences lumineuses :
Exemple d'un dispositif interférentiel à division d'amplitude : l'interféromètre de Michelson

- description

   - schéma

   - composants

   - trajet de la lumière

   - richesses du Michelson

   - en pratique, introduction d'une compensatrice

   - méthode d'étude, repliement du Michelson

- Utilisation en lame d'aire

   - où sont les interférences dans le cas d'une source ponctuelle ? Allure ?

   - remarque sur le fait que le nombre d'anneaux augmente quand l'épaisseur de la lame d'air augmente.

   - où sont les interférences dans le cas d'une source étendue ? Localisation à l'infini. Allure.
Remarque : 2 droites parallèles peuvent être vues comme deux droites qui se croisent en l'infini.

   - calcul de la différence de marche à l'infini.

   - lien entre l'inclinaison et la position de M sur l'écran lorsque l'écran est placé dans le plan focal image d'une lentille convergente.

TD : exercice sur la mesure d'un indice d'un gaz, et sur les miroirs de Fresnel.

A faire :

- pour lundi 12 octobre, réfléchir à l'allure des anneaux sur l'écran d'observations : vont-ils être resserrés, répartis de manière homogène, de moins en moins serrés ?

- pour vendredi 16 octobre, DM sur des interférences.


text:
.class Landroid/graphics/drawable/StateListDrawable$StateListState;
.super Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;
.source "StateListDrawable.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/graphics/drawable/StateListDrawable;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x8
    name = "StateListState"
.end annotation

# instance fields
.field mStateSets:[[I

.field mThemeAttrs:[I

# direct methods
.method constructor <init>(Landroid/graphics/drawable/StateListDrawable$StateListState;Landroid/graphics/drawable/StateListDrawable;Landroid/content/res/Resources;)V
    .locals 1

    const/4 v0, 0x0

    invoke-direct {p0, p1, p2, p3}, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;-><init>(Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;Landroid/graphics/drawable/DrawableContainer;Landroid/content/res/Resources;)V

    if-eqz p1, :cond_0

    iget-object v0, p1, Landroid/graphics/drawable/StateListDrawable$StateListState;->mThemeAttrs:[I

    iput-object v0, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mThemeAttrs:[I

    iget-object v0, p1, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    iput-object v0, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    :goto_0
    return-void

    :cond_0
    iput-object v0, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mThemeAttrs:[I

    invoke-virtual {p0}, Landroid/graphics/drawable/StateListDrawable$StateListState;->getCapacity()I

    move-result v0

    new-array v0, v0, [[I

    iput-object v0, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    goto :goto_0
.end method

# virtual methods
.method addStateSet([ILandroid/graphics/drawable/Drawable;)I
    .locals 2

    invoke-virtual {p0, p2}, Landroid/graphics/drawable/StateListDrawable$StateListState;->addChild(Landroid/graphics/drawable/Drawable;)I

    move-result v0

    iget-object v1, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    aput-object p1, v1, v0

    return v0
.end method

.method public canApplyTheme()Z
    .locals 1

    iget-object v0, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mThemeAttrs:[I

    if-nez v0, :cond_0

    invoke-super {p0}, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;->canApplyTheme()Z

    move-result v0

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x1

    goto :goto_0
.end method

.method public growArray(II)V
    .locals 3

    const/4 v2, 0x0

    invoke-super {p0, p1, p2}, Landroid/graphics/drawable/DrawableContainer$DrawableContainerState;->growArray(II)V

    new-array v0, p2, [[I

    iget-object v1, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    invoke-static {v1, v2, v0, v2, p1}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    iput-object v0, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    return-void
.end method

.method hasFocusStateSpecified()Z
    .locals 2

    iget-object v0, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    const v1, 0x101009c

    invoke-static {v0, v1}, Landroid/util/StateSet;->containsAttribute([[II)Z

    move-result v0

    return v0
.end method

.method indexOfStateSet([I)I
    .locals 4

    iget-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    invoke-virtual {p0}, Landroid/graphics/drawable/StateListDrawable$StateListState;->getChildCount()I

    move-result v0

    const/4 v1, 0x0

    :goto_0
    if-ge v1, v0, :cond_1

    aget-object v3, v2, v1

    invoke-static {v3, p1}, Landroid/util/StateSet;->stateSetMatches([I[I)Z

    move-result v3

    if-eqz v3, :cond_0

    return v1

    :cond_0
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    :cond_1
    const/4 v3, -0x1

    return v3
.end method

.method mutate()V
    .locals 4

    const/4 v3, 0x0

    iget-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mThemeAttrs:[I

    if-eqz v2, :cond_0

    iget-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mThemeAttrs:[I

    invoke-virtual {v2}, Ljava/lang/Object;->clone()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, [I

    :goto_0
    iput-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mThemeAttrs:[I

    iget-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    array-length v2, v2

    new-array v1, v2, [[I

    iget-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    array-length v2, v2

    add-int/lit8 v0, v2, -0x1

    :goto_1
    if-ltz v0, :cond_2

    iget-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    aget-object v2, v2, v0

    if-eqz v2, :cond_1

    iget-object v2, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    aget-object v2, v2, v0

    invoke-virtual {v2}, Ljava/lang/Object;->clone()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, [I

    :goto_2
    aput-object v2, v1, v0

    add-int/lit8 v0, v0, -0x1

    goto :goto_1

    :cond_0
    move-object v2, v3

    goto :goto_0

    :cond_1
    move-object v2, v3

    goto :goto_2

    :cond_2
    iput-object v1, p0, Landroid/graphics/drawable/StateListDrawable$StateListState;->mStateSets:[[I

    return-void
.end method

.method public newDrawable()Landroid/graphics/drawable/Drawable;
    .locals 2

    const/4 v1, 0x0

    new-instance v0, Landroid/graphics/drawable/StateListDrawable;

    invoke-direct {v0, p0, v1, v1}, Landroid/graphics/drawable/StateListDrawable;-><init>(Landroid/graphics/drawable/StateListDrawable$StateListState;Landroid/content/res/Resources;Landroid/graphics/drawable/StateListDrawable;)V

    return-object v0
.end method

.method public newDrawable(Landroid/content/res/Resources;)Landroid/graphics/drawable/Drawable;
    .locals 2

    new-instance v0, Landroid/graphics/drawable/StateListDrawable;

    const/4 v1, 0x0

    invoke-direct {v0, p0, p1, v1}, Landroid/graphics/drawable/StateListDrawable;-><init>(Landroid/graphics/drawable/StateListDrawable$StateListState;Landroid/content/res/Resources;Landroid/graphics/drawable/StateListDrawable;)V

    return-object v0
.end method


text:
<?php

/**
 * DmWidget form base class.
 *
 * @method DmWidget getObject() Returns the current form's model object
 *
 * @package    retest
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id$
 */
abstract class BaseDmWidgetForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'         => new sfWidgetFormInputHidden(),
      'dm_zone_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Zone'), 'add_empty' => false)),
      'module'     => new sfWidgetFormInputText(),
      'action'     => new sfWidgetFormInputText(),
      'css_class'  => new sfWidgetFormInputText(),
      'position'   => new sfWidgetFormInputText(),
      'updated_at' => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'         => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'dm_zone_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Zone'))),
      'module'     => new sfValidatorString(array('max_length' => 127)),
      'action'     => new sfValidatorString(array('max_length' => 127)),
      'css_class'  => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'position'   => new sfValidatorInteger(array('required' => false)),
      'updated_at' => new sfValidatorDateTime(),
    ));

		if('embed' == sfConfig::get('dm_i18n_form'))
    {
      $this->embedI18n(sfConfig::get('dm_i18n_cultures'));
    }
    else
    {
      $this->mergeI18nForm();
		}

    $this->widgetSchema->setNameFormat('dm_widget[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();

    // Unset automatic fields like 'created_at', 'updated_at', 'position'
    // override this method in your form to keep them
    parent::unsetAutoFields();
  }

  protected function doBind(array $values)
  {
    parent::doBind($values);
  }

  public function processValues($values)
  {
    $values = parent::processValues($values);
    return $values;
  }

  protected function doUpdateObject($values)
  {
    parent::doUpdateObject($values);
  }

  public function getModelName()
  {
    return 'DmWidget';
  }

}