Dataset Preview
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code: DatasetGenerationError
Exception: ArrowInvalid
Message: JSON parse error: Missing a closing quotation mark in string. in row 963
Traceback: Traceback (most recent call last):
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 145, in _generate_tables
dataset = json.load(f)
File "/usr/local/lib/python3.9/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.9/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 2983)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1995, in _prepare_split_single
for _, table in generator:
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 148, in _generate_tables
raise e
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/packaged_modules/json/json.py", line 122, in _generate_tables
pa_table = paj.read_json(
File "pyarrow/_json.pyx", line 308, in pyarrow._json.read_json
File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: JSON parse error: Missing a closing quotation mark in string. in row 963
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1529, in compute_config_parquet_and_info_response
parquet_operations = convert_to_parquet(builder)
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1154, in convert_to_parquet
builder.download_and_prepare(
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1027, in download_and_prepare
self._download_and_prepare(
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1122, in _download_and_prepare
self._prepare_split(split_generator, **prepare_split_kwargs)
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1882, in _prepare_split
for job_id, done, content in self._prepare_split_single(
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2038, in _prepare_split_single
raise DatasetGenerationError("An error occurred while generating the dataset") from e
datasets.exceptions.DatasetGenerationError: An error occurred while generating the datasetNeed help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
text
string | meta
dict |
|---|---|
<?
if (!class_exists("DBBase")) {
include("objects/db.class.php");
}
if (!class_exists("Stock")){
include("objects/stock.class.php");
}
if (!class_exists("User")){
//include("objects/user.class.php");
}
include("objects/portfolio.class.php");
//head.php
//echo $title;
/*if ((!eregi("Home",$title) && !eregi("Research",$title)) && !$HTTP_COOKIE_VARS["gtsficg-user"]){
//if not logged in redirect
header("Location: index.php");
} */
echo "<html>\n";
echo "<head>\n";
echo "\t<title>$title--GT Investment Challenge</title>\n";
echo "<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">";
?>
</head>
<body>
<div id="head"></div>
<div id="menu" style="position:absolute;top:80;background:#265aa6;">
<!--Home
Manage
Research
Competition
IC Home-->
<span class="mleft"></span>
<div class="box"><a href="index.php">Home</a></div><div class="boxx"><div class="boxx1"></div><div class="boxx2"></div><div class="boxx3"></div><div class="boxx4"></div><div class="boxx5"></div><div class="boxx6"></div><div class="boxx7"></div><div class="boxx8"></div></div>
<div class="box"><a href="manage.php">Manage</a></div><div class="boxx"><div class="boxx1"></div><div class="boxx2"></div><div class="boxx3"></div><div class="boxx4"></div><div class="boxx5"></div><div class="boxx6"></div><div class="boxx7"></div><div class="boxx8"></div></div>
<div class="box"><a href="research.php">Research</a></div><div class="boxx"><div class="boxx1"></div><div class="boxx2"></div><div class="boxx3"></div><div class="boxx4"></div><div class="boxx5"></div><div class="boxx6"></div><div class="boxx7"></div><div class="boxx8"></div></div>
<div class="box"><a href="competition.php">Competition</a></div><div class="boxx"><div class="boxx1"></div><div class="boxx2"></div><div class="boxx3"></div><div class="boxx4"></div><div class="boxx5"></div><div class="boxx6"></div><div class="boxx7"></div><div class="boxx8"></div></div>
<div class="box"><a href="http://gtsf.gatech.edu/ic/">IC Home</a></div>
<span class="mright"></span>
</div>
<div id="content">
|
{
"content_hash": "0419993c6c2b5c30d9423aae0091dc7a",
"timestamp": "",
"source": "github",
"line_count": 51,
"max_line_length": 304,
"avg_line_length": 42.15686274509804,
"alnum_prop": 0.6093023255813953,
"repo_name": "stephenreid/GT-Student-Foundation-Investment-Challenge",
"id": "4b61374c2af0a46d6d9b269bc3fd7856dc917a48",
"size": "2150",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "head.php",
"mode": "33261",
"license": "mit",
"language": [
{
"name": "CSS",
"bytes": "5178"
},
{
"name": "PHP",
"bytes": "27965"
}
]
}
|
package org.jongo.model;
import org.jongo.marshall.jackson.oid.Id;
import org.jongo.marshall.jackson.oid.MongoId;
public class ExternalFriend {
@Id
@MongoId //see NewAnnotationsCompatibilitySuiteTest for more informations
private String id;
private String name;
private ExternalFriend() {
//jackson
}
public ExternalFriend(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static ExternalFriend createFriendWithoutId(String name) {
ExternalFriend friend = new ExternalFriend();
friend.setName(name);
return friend;
}
}
|
{
"content_hash": "d6737f7cee4d2330d71557e7f9a35bf8",
"timestamp": "",
"source": "github",
"line_count": 41,
"max_line_length": 77,
"avg_line_length": 19.902439024390244,
"alnum_prop": 0.6360294117647058,
"repo_name": "edwardmlyte/jongo",
"id": "42b06fd929af802b331eb6c30540a27fe0ac59df",
"size": "1500",
"binary": false,
"copies": "8",
"ref": "refs/heads/master",
"path": "src/test/java/org/jongo/model/ExternalFriend.java",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "Java",
"bytes": "371856"
},
{
"name": "Shell",
"bytes": "1929"
}
]
}
|
package lejos.remote.ev3;
import java.rmi.Remote;
import java.rmi.RemoteException;
import lejos.hardware.lcd.Font;
public interface RMIEV3 extends Remote {
public RMIAnalogPort openAnalogPort(String portName) throws RemoteException;
public RMII2CPort openI2CPort(String portName) throws RemoteException;
public RMIBattery getBattery() throws RemoteException;
public RMIUARTPort openUARTPort(String portName) throws RemoteException;
public RMIMotorPort openMotorPort(String portName) throws RemoteException;
public RMISampleProvider createSampleProvider(String portName, String sensorName, String modeName) throws RemoteException;
public RMIRegulatedMotor createRegulatedMotor(String portName, char motorType) throws RemoteException;
public RMIAudio getAudio() throws RemoteException;
public RMITextLCD getTextLCD() throws RemoteException;
public RMITextLCD getTextLCD(Font f) throws RemoteException;
public RMIGraphicsLCD getGraphicsLCD() throws RemoteException;
public RMIWifi getWifi() throws RemoteException;
public RMIBluetooth getBluetooth() throws RemoteException;
public String getName() throws RemoteException;
public RMIKey getKey(String name) throws RemoteException;
public RMILED getLED() throws RemoteException;
public RMIKeys getKeys() throws RemoteException;
}
|
{
"content_hash": "5cff121181c5a4968d98fe2f11f27589",
"timestamp": "",
"source": "github",
"line_count": 44,
"max_line_length": 123,
"avg_line_length": 30.113636363636363,
"alnum_prop": 0.8241509433962264,
"repo_name": "antoniardot/DockBot-Eve",
"id": "a40253ae39057e83609b62fc26472db4f1d4d5f1",
"size": "1325",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "lib/lejos/remote/ev3/RMIEV3.java",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "Java",
"bytes": "2139498"
}
]
}
|
package it.cnr.isti.zigbee.ha.cluster.glue.general;
import it.cnr.isti.zigbee.ha.cluster.glue.Cluster;
import it.cnr.isti.zigbee.ha.driver.core.ZigBeeHAException;
import it.cnr.isti.zigbee.zcl.library.api.core.Attribute;
import it.cnr.isti.zigbee.zcl.library.api.general.alarms.AlarmListener;
import it.cnr.isti.zigbee.zcl.library.api.general.alarms.GetAlarmResponse;
/**
*
* @author <a href="mailto:stefano.lenzi@isti.cnr.it">Stefano "Kismet" Lenzi</a>
* @author <a href="mailto:francesco.furfari@isti.cnr.it">Francesco Furfari</a>
* @version $LastChangedRevision$ ($LastChangedDate$)
*
*/
public interface Alarms extends Cluster {
public Attribute getAttributeAlarmCount();
public void resetAlarm(int clusterId, int attributeId) throws ZigBeeHAException;
public void resetAllAlarms() throws ZigBeeHAException;
public GetAlarmResponse getAlarm() throws ZigBeeHAException;
public void resetAlarmLog() throws ZigBeeHAException;
public boolean addAlarmListener(AlarmListener listener);
public boolean removeAlarmListerner(AlarmListener listener);
}
|
{
"content_hash": "291861a83bb7819ee08b680509330cca",
"timestamp": "",
"source": "github",
"line_count": 33,
"max_line_length": 84,
"avg_line_length": 33.24242424242424,
"alnum_prop": 0.7757520510483136,
"repo_name": "cdealti/zb4osgi",
"id": "2aeaa33478ec7e434090c55a3485e3721d8e0dbc",
"size": "1916",
"binary": false,
"copies": "2",
"ref": "refs/heads/master",
"path": "zb4o-ha-driver/src/main/java/it/cnr/isti/zigbee/ha/cluster/glue/general/Alarms.java",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "Java",
"bytes": "3676977"
}
]
}
|
package demo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Ignore;
import org.junit.Test;
public class ShortcutsTest
{
@Test
public void testFindFirstSeq()
throws Exception
{
assertEquals("Niklas Schuster", new Shortcuts().findFirstSeq("niklas schuster"));
assertNull(new Shortcuts().findFirstSeq("topalo"));
}
@Test
@Ignore
public void testFindFirstPar()
throws Exception
{
assertEquals("Niklas Schuster", new Shortcuts().findFirstPar("niklas schuster"));
assertNull(new Shortcuts().findFirstPar("topalo"));
}
@Test
@Ignore
public void testFindFirstFor()
throws Exception
{
assertEquals("Niklas Schuster", new Shortcuts().findFirstFor("niklas schuster"));
assertNull(new Shortcuts().findFirstFor("topalo"));
}
}
|
{
"content_hash": "30fd2b1d65ba94b6c114089b674e0dc8",
"timestamp": "",
"source": "github",
"line_count": 38,
"max_line_length": 85,
"avg_line_length": 22.210526315789473,
"alnum_prop": 0.7180094786729858,
"repo_name": "goeckeler/katas",
"id": "3a213445804eec6a47d8817b4ad268646d37f88d",
"size": "844",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "katas/Lambdas/speed/kata/src/demo/ShortcutsTest.java",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "Batchfile",
"bytes": "284"
},
{
"name": "Java",
"bytes": "145066"
},
{
"name": "Scala",
"bytes": "515"
},
{
"name": "Shell",
"bytes": "309"
}
]
}
|
package com.xeonwell.JerseyDemo.controller;
/**
* Created by xeonwell on 2017-04-24.
*/
import com.xeonwell.JerseyDemo.common.BaseApiController;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/hello")
public class HelloWorldController extends BaseApiController {
//GET注解设置接受请求类型为GET
@GET
//Produces表明发送出去的数据类型为text/plain
// 与Produces对应的是@Consumes,表示接受的数据类型为text/plain
@Produces("text/plain")
public String getMessage() {
logger.debug("hello world.");
return "Hello world!";
}
}
|
{
"content_hash": "64627a5e182bb0ae6bbbd951791862b3",
"timestamp": "",
"source": "github",
"line_count": 25,
"max_line_length": 61,
"avg_line_length": 22.64,
"alnum_prop": 0.7137809187279152,
"repo_name": "xeonwell/JerseyDemo",
"id": "e282614319ce8706bbb1079d9ab8902100c26548",
"size": "644",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "src/main/java/com/xeonwell/JerseyDemo/controller/HelloWorldController.java",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "HTML",
"bytes": "127"
},
{
"name": "Java",
"bytes": "39075"
}
]
}
|
name = 'Zed A. Shaw'
age = 35 # not a lie
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
print "Let's talk about %s." % name
print "He's %d inches tall." % height
print "He's %d pounds heavy." % weight
print "Actually that's not too heavy."
print "He's got %s eyes and %s hair." % (eyes, hair)
print "His teeth are usually %s depending on the coffee." % teeth
# this line is tricky, try to get it exactly right
print "If I add %d, %d, and %d I get %d." % (
age, height, weight, age + height + weight)
# Study drills
height_cm = height * 2.54 # cm
weight_kg = weight * 0.453592 # kg
print "He's %d centimeters tall." % height_cm
print "He's %d kilograms heavy." % weight_kg
# %r format character
r = "Print this no matter what"
print "Here is what %%r does: %r" % r
|
{
"content_hash": "854c5f1875667a965d9a95492cf252a9",
"timestamp": "",
"source": "github",
"line_count": 30,
"max_line_length": 65,
"avg_line_length": 27.1,
"alnum_prop": 0.6482164821648216,
"repo_name": "richardcornish/richlearnspythonthehardway",
"id": "8c018c3d07cd20691492fff0b9178d80b8bdabe6",
"size": "877",
"binary": false,
"copies": "2",
"ref": "refs/heads/master",
"path": "exercises/ex05.py",
"mode": "33188",
"license": "bsd-3-clause",
"language": [
{
"name": "CSS",
"bytes": "14760"
},
{
"name": "HTML",
"bytes": "15173"
},
{
"name": "Python",
"bytes": "32832"
},
{
"name": "Shell",
"bytes": "2201"
}
]
}
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.EditAndContinue.UnitTests;
internal class MockPdbMatchingSourceTextProvider : IPdbMatchingSourceTextProvider
{
public Func<string, ImmutableArray<byte>, SourceHashAlgorithm, string?>? TryGetMatchingSourceTextImpl;
public ValueTask<string?> TryGetMatchingSourceTextAsync(string filePath, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
=> ValueTaskFactory.FromResult(TryGetMatchingSourceTextImpl?.Invoke(filePath, requiredChecksum, checksumAlgorithm));
}
|
{
"content_hash": "04b7c7abb4254349d3b2fbd4e116e64a",
"timestamp": "",
"source": "github",
"line_count": 20,
"max_line_length": 191,
"avg_line_length": 47.05,
"alnum_prop": 0.8278427205100957,
"repo_name": "dotnet/roslyn",
"id": "b9161fd745c5b5a1f755ac7c46cd34b4ab4ff960",
"size": "943",
"binary": false,
"copies": "6",
"ref": "refs/heads/main",
"path": "src/EditorFeatures/Test/EditAndContinue/Helpers/MockPdbMatchingSourceTextProvider.cs",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "1C Enterprise",
"bytes": "257760"
},
{
"name": "Batchfile",
"bytes": "8186"
},
{
"name": "C#",
"bytes": "177013904"
},
{
"name": "C++",
"bytes": "5602"
},
{
"name": "CMake",
"bytes": "12939"
},
{
"name": "Dockerfile",
"bytes": "441"
},
{
"name": "F#",
"bytes": "549"
},
{
"name": "PowerShell",
"bytes": "284790"
},
{
"name": "Shell",
"bytes": "134009"
},
{
"name": "Vim Snippet",
"bytes": "6353"
},
{
"name": "Visual Basic .NET",
"bytes": "74255416"
}
]
}
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_102) on Thu Sep 29 16:37:37 CEST 2016 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>energy.usef.brp.workflow.plan.flexoffer.revoke Class Hierarchy (usef-root-pom 1.3.6 API)</title>
<meta name="date" content="2016-09-29">
<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="energy.usef.brp.workflow.plan.flexoffer.revoke Class Hierarchy (usef-root-pom 1.3.6 API)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li>Use</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../../energy/usef/brp/workflow/plan/connection/forecast/package-tree.html">Prev</a></li>
<li><a href="../../../../../../../energy/usef/brp/workflow/plan/flexorder/acknowledge/package-tree.html">Next</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?energy/usef/brp/workflow/plan/flexoffer/revoke/package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 class="title">Hierarchy For Package energy.usef.brp.workflow.plan.flexoffer.revoke</h1>
<span class="packageHierarchyLabel">Package Hierarchies:</span>
<ul class="horizontal">
<li><a href="../../../../../../../overview-tree.html">All Packages</a></li>
</ul>
</div>
<div class="contentContainer">
<h2 title="Class Hierarchy">Class Hierarchy</h2>
<ul>
<li type="circle">java.lang.<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang"><span class="typeNameLink">Object</span></a>
<ul>
<li type="circle">energy.usef.brp.workflow.plan.flexoffer.revoke.<a href="../../../../../../../energy/usef/brp/workflow/plan/flexoffer/revoke/BrpFlexOfferRevocationCoordinator.html" title="class in energy.usef.brp.workflow.plan.flexoffer.revoke"><span class="typeNameLink">BrpFlexOfferRevocationCoordinator</span></a></li>
<li type="circle">energy.usef.brp.workflow.plan.flexoffer.revoke.<a href="../../../../../../../energy/usef/brp/workflow/plan/flexoffer/revoke/FlexOfferRevocationEvent.html" title="class in energy.usef.brp.workflow.plan.flexoffer.revoke"><span class="typeNameLink">FlexOfferRevocationEvent</span></a></li>
</ul>
</li>
</ul>
<h2 title="Enum Hierarchy">Enum Hierarchy</h2>
<ul>
<li type="circle">java.lang.<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang"><span class="typeNameLink">Object</span></a>
<ul>
<li type="circle">java.lang.<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html?is-external=true" title="class or interface in java.lang"><span class="typeNameLink">Enum</span></a><E> (implements java.lang.<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html?is-external=true" title="class or interface in java.lang">Comparable</a><T>, java.io.<a href="http://docs.oracle.com/javase/8/docs/api/java/io/Serializable.html?is-external=true" title="class or interface in java.io">Serializable</a>)
<ul>
<li type="circle">energy.usef.brp.workflow.plan.flexoffer.revoke.<a href="../../../../../../../energy/usef/brp/workflow/plan/flexoffer/revoke/BrpFlexOfferRevocationError.html" title="enum in energy.usef.brp.workflow.plan.flexoffer.revoke"><span class="typeNameLink">BrpFlexOfferRevocationError</span></a> (implements energy.usef.core.exception.<a href="../../../../../../../energy/usef/core/exception/BusinessError.html" title="interface in energy.usef.core.exception">BusinessError</a>)</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li>Class</li>
<li>Use</li>
<li class="navBarCell1Rev">Tree</li>
<li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../../../energy/usef/brp/workflow/plan/connection/forecast/package-tree.html">Prev</a></li>
<li><a href="../../../../../../../energy/usef/brp/workflow/plan/flexorder/acknowledge/package-tree.html">Next</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../index.html?energy/usef/brp/workflow/plan/flexoffer/revoke/package-tree.html" target="_top">Frames</a></li>
<li><a href="package-tree.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright © 2016. All rights reserved.</small></p>
</body>
</html>
|
{
"content_hash": "ff8e81c7c821a675a7bbaf708a1a5ae1",
"timestamp": "",
"source": "github",
"line_count": 152,
"max_line_length": 546,
"avg_line_length": 47.92763157894737,
"alnum_prop": 0.6301990391214825,
"repo_name": "FHPproject/FHPUsef",
"id": "b42728b82c91651364dcbb8cd83e5de44883965d",
"size": "7285",
"binary": false,
"copies": "2",
"ref": "refs/heads/master",
"path": "usef-javadoc/energy/usef/brp/workflow/plan/flexoffer/revoke/package-tree.html",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "Batchfile",
"bytes": "25252"
},
{
"name": "CSS",
"bytes": "13416"
},
{
"name": "HTML",
"bytes": "33111187"
},
{
"name": "Java",
"bytes": "6924158"
},
{
"name": "JavaScript",
"bytes": "857"
},
{
"name": "PowerShell",
"bytes": "6025"
},
{
"name": "Shell",
"bytes": "18804"
},
{
"name": "TSQL",
"bytes": "407953"
}
]
}
|
package com.blazingphoenix.iprepared;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Locale;
public class MainActivity extends Activity implements ActionBar.TabListener {
private static final String TABLE_TASKS = "tasks";
private static final String TABLE_HOME = "home";
private static final String TABLE_CAR = "car";
private static final String TABLE_WORK = "work";
/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a
* {@link FragmentPagerAdapter} derivative, which will keep every
* loaded fragment in memory. If this becomes too memory intensive, it
* may be best to switch to a
* {@link android.support.v13.app.FragmentStatePagerAdapter}.
*/
SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Set up the action bar.
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create the adapter that will return a fragment for each of the three
// primary sections of the activity.
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(
actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
Toast.makeText(this, "There are no settings for this app!", Toast.LENGTH_LONG).show();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a DashboardFragment (defined as a static inner class below).
switch (position) {
case 0:
return DashboardFragment.newInstance(position);
case 1:
return new FactsFragment();
case 2:
return new DrillReminder();
case 3:
return TaskList.newInstance(TABLE_WORK);
case 4:
return TaskList.newInstance(TABLE_TASKS);
case 5:
return TaskList.newInstance(TABLE_CAR);
case 6:
return TaskList.newInstance(TABLE_HOME);
case 7:
return new ExpiriesFragment();
}
return null;
}
@Override
public int getCount() {
// Show 5 total pages.
return 8;
}
@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.title_section1).toUpperCase(l);
case 1:
return getString(R.string.title_section2).toUpperCase(l);
case 2:
return getString(R.string.title_section3).toUpperCase(l);
case 3:
return getString(R.string.title_section7).toUpperCase(l);
case 4:
return getString(R.string.title_section5).toUpperCase(l);
case 5:
return getString(R.string.title_section6).toUpperCase(l);
case 6:
return getString(R.string.title_section4).toUpperCase(l);
case 7:
return getString(R.string.title_section8).toUpperCase(l);
}
return null;
}
}
/**
* A placeholder fragment containing a simple view.
*/
public static class DashboardFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static DashboardFragment newInstance(int sectionNumber) {
DashboardFragment fragment = new DashboardFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
public DashboardFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
TextView percentageTV = null;
if (rootView != null) {
percentageTV = (TextView) rootView.findViewById(R.id.mainPercentDone);
}
SQLiteHelper db = new SQLiteHelper(getActivity());
String percentage = db.getPercentage();
//Log.d("MainActivity", "PERCENTAGE: " + percentage);
db.closeDB();
if (percentageTV != null) {
percentageTV.setText(percentage + "% Completed");
}
return rootView;
}
}
}
|
{
"content_hash": "7346db4851c5ad46a17e1ac3228a969d",
"timestamp": "",
"source": "github",
"line_count": 234,
"max_line_length": 98,
"avg_line_length": 36.74786324786325,
"alnum_prop": 0.6003023607396208,
"repo_name": "bestvibes/iPrepared",
"id": "151f786caba0bcf6ddc2a912c920e4056977897f",
"size": "8599",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "iPrepared/src/main/java/com/blazingphoenix/iprepared/MainActivity.java",
"mode": "33261",
"license": "mit",
"language": [
{
"name": "Java",
"bytes": "51868"
}
]
}
|
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import wagtail.wagtailcore.fields
class Migration(migrations.Migration):
initial = True
dependencies = [
('wagtailcore', '0033_remove_golive_expiry_help_text'),
]
operations = [
migrations.CreateModel(
name='BlogIndexPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')),
('intro', wagtail.wagtailcore.fields.RichTextField(blank=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
|
{
"content_hash": "35faf1cdeb0f9f019223e99a795e1e79",
"timestamp": "",
"source": "github",
"line_count": 28,
"max_line_length": 191,
"avg_line_length": 29.535714285714285,
"alnum_prop": 0.6070133010882709,
"repo_name": "joecheng511/try-wagtail",
"id": "0c8457d7dbb05df0020022fa4c7ffc41c4b6e2ef",
"size": "900",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "mysite/blog/migrations/0001_initial.py",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "CSS",
"bytes": "197606"
},
{
"name": "HTML",
"bytes": "8437"
},
{
"name": "JavaScript",
"bytes": "185435"
},
{
"name": "Python",
"bytes": "37442"
}
]
}
|
#pragma once
#include "library/tactic/tactic_state.h"
#include "library/tactic/elaborator_exception.h"
#include "library/vm/interaction_state.h"
namespace lean {
elaborator_exception unsolved_tactic_state(tactic_state const & ts, format const & fmt, expr const & ref);
elaborator_exception unsolved_tactic_state(tactic_state const & ts, char const * msg, expr const & ref);
[[noreturn]] void throw_unsolved_tactic_state(tactic_state const & ts, format const & fmt, expr const & ref);
[[noreturn]] void throw_unsolved_tactic_state(tactic_state const & ts, char const * msg, expr const & ref);
class tactic_evaluator : public tactic::evaluator {
private:
expr m_ref;
protected:
virtual void process_failure(vm_state & S, vm_obj const & r) override;
public:
tactic_evaluator(type_context & ctx, options const & opts, expr const & ref):
tactic::evaluator(ctx, opts), m_ref(ref) {}
virtual vm_obj operator()(expr const & tactic, buffer<vm_obj> const & args, tactic_state const & s) override;
vm_obj operator()(expr const & tactic, tactic_state const & s) {
return tactic::evaluator::operator()(tactic, s);
}
};
}
|
{
"content_hash": "49f7f1f21a0b720ad7a40bbf0a1cf164",
"timestamp": "",
"source": "github",
"line_count": 26,
"max_line_length": 113,
"avg_line_length": 44.42307692307692,
"alnum_prop": 0.7082251082251082,
"repo_name": "rlewis1988/lean",
"id": "7e868e7edf70c4c4f572c8d39740659f56fbac5e",
"size": "1318",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "src/library/tactic/tactic_evaluator.h",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "Batchfile",
"bytes": "134"
},
{
"name": "C",
"bytes": "61602"
},
{
"name": "C++",
"bytes": "6350761"
},
{
"name": "CMake",
"bytes": "77898"
},
{
"name": "Emacs Lisp",
"bytes": "120591"
},
{
"name": "Gherkin",
"bytes": "278"
},
{
"name": "HTML",
"bytes": "2694"
},
{
"name": "Lean",
"bytes": "1469714"
},
{
"name": "Lex",
"bytes": "79"
},
{
"name": "Lua",
"bytes": "105"
},
{
"name": "Makefile",
"bytes": "185"
},
{
"name": "Perl",
"bytes": "6445"
},
{
"name": "Python",
"bytes": "32936"
},
{
"name": "SMT",
"bytes": "5828"
},
{
"name": "Shell",
"bytes": "29766"
},
{
"name": "TeX",
"bytes": "10366"
}
]
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
namespace RSSE.ShipElements.Systems
{
public class RCSSystem : SubSystem
{
override public string SystemName { get { return "RCS"; } }
override public string SystemGroup { get { return "Propulsion"; } }
public BindingList<RCS> rcs { get; set; }
public RCSSystem()
{
rcs = new BindingList<RCS>();
}
public RCSSystem( ShipTable table )
{
rcs = new BindingList<RCS>();
int i = 1;
while (table.shipCoords["Thruster" + i].Count > 0)
{
rcs.Add(new RCS(table.shipCoords["Thruster" + i]));
i++;
}
}
override public void AddToTable(ShipTable table)
{
int i = 1;
foreach (RCS thruster in rcs)
{
table.shipCoords["Thruster" + i] = thruster.ToTable();
i++;
}
}
}
}
|
{
"content_hash": "27454ed7685908b3f92c2ec9a53f1c09",
"timestamp": "",
"source": "github",
"line_count": 43,
"max_line_length": 75,
"avg_line_length": 26.488372093023255,
"alnum_prop": 0.5030728709394205,
"repo_name": "Enyss/RSSE",
"id": "ef19b99666bf0c23bcecc5d31ed71e091e05a253",
"size": "1141",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "Model/Systems/RCSSystem.cs",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "C#",
"bytes": "359312"
}
]
}
|
"""
checks.py
Each function in here should
- Take a DataFrame as its first argument, maybe optional arguments
- Makes its assert on the result
- Return the original DataFrame
"""
import numpy as np
import pandas as pd
import pandas.util.testing as tm
import six
from engarde import generic
from engarde.generic import verify, verify_all, verify_any
def none_missing(df, columns=None):
"""
Asserts that there are no missing values (NaNs) in the DataFrame.
Parameters
----------
df : DataFrame
columns : list
list of columns to restrict the check to
Returns
-------
df : DataFrame
same as the original
"""
if columns is None:
columns = df.columns
try:
assert not df[columns].isnull().any().any()
except AssertionError as e:
missing = df[columns].isnull()
msg = generic.bad_locations(missing)
e.args = msg
raise
return df
def is_monotonic(df, items=None, increasing=None, strict=False):
"""
Asserts that the DataFrame is monotonic.
Parameters
==========
df : Series or DataFrame
items : dict
mapping columns to conditions (increasing, strict)
increasing : None or bool
None is either increasing or decreasing.
strict : whether the comparison should be strict
Returns
=======
df : DataFrame
"""
if items is None:
items = {k: (increasing, strict) for k in df}
for col, (increasing, strict) in items.items():
s = pd.Index(df[col])
if increasing:
good = getattr(s, 'is_monotonic_increasing')
elif increasing is None:
good = getattr(s, 'is_monotonic') | getattr(s, 'is_monotonic_decreasing')
else:
good = getattr(s, 'is_monotonic_decreasing')
if strict:
if increasing:
good = good & (s.to_series().diff().dropna() > 0).all()
elif increasing is None:
good = good & ((s.to_series().diff().dropna() > 0).all() |
(s.to_series().diff().dropna() < 0).all())
else:
good = good & (s.to_series().diff().dropna() < 0).all()
if not good:
raise AssertionError
return df
def is_shape(df, shape):
"""
Asserts that the DataFrame is of a known shape.
Parameters
==========
df : DataFrame
shape : tuple
(n_rows, n_columns). Use None or -1 if you don't care
about a dimension.
Returns
=======
df : DataFrame
"""
try:
check = np.all(np.equal(df.shape, shape) | (np.equal(shape, [-1, -1]) |
np.equal(shape, [None, None])))
assert check
except AssertionError as e:
msg = ("Expected shape: {}\n"
"\t\tActual shape: {}".format(shape, df.shape))
e.args = (msg,)
raise
return df
def unique(df, columns=None):
"""
Asserts that columns in the DataFrame only have unique values.
Parameters
----------
df : DataFrame
columns : list
list of columns to restrict the check to. If None, check all columns.
Returns
-------
df : DataFrame
same as the original
"""
if columns is None:
columns = df.columns
for col in columns:
if not df[col].is_unique:
raise AssertionError("Column {!r} contains non-unique values".format(col))
return df
def unique_index(df):
"""
Assert that the index is unique
Parameters
==========
df : DataFrame
Returns
=======
df : DataFrame
"""
try:
assert df.index.is_unique
except AssertionError as e:
e.args = df.index.get_duplicates()
raise
return df
def within_set(df, items=None):
"""
Assert that df is a subset of items
Parameters
==========
df : DataFrame
items : dict
mapping of columns (k) to array-like of values (v) that
``df[k]`` is expected to be a subset of
Returns
=======
df : DataFrame
"""
for k, v in items.items():
if not df[k].isin(v).all():
bad = df.loc[~df[k].isin(v), k]
raise AssertionError('Not in set', bad)
return df
def within_range(df, items=None):
"""
Assert that a DataFrame is within a range.
Parameters
==========
df : DataFame
items : dict
mapping of columns (k) to a (low, high) tuple (v)
that ``df[k]`` is expected to be between.
Returns
=======
df : DataFrame
"""
for k, (lower, upper) in items.items():
if (lower > df[k]).any() or (upper < df[k]).any():
bad = (lower > df[k]) | (upper < df[k])
raise AssertionError("Outside range", bad)
return df
def within_n_std(df, n=3):
"""
Assert that every value is within ``n`` standard
deviations of its column's mean.
Parameters
==========
df : DataFame
n : int
number of standard deviations from the mean
Returns
=======
df : DataFrame
"""
means = df.mean()
stds = df.std()
inliers = (np.abs(df[means.index] - means) < n * stds)
if not np.all(inliers):
msg = generic.bad_locations(~inliers)
raise AssertionError(msg)
return df
def has_dtypes(df, items):
"""
Assert that a DataFrame has ``dtypes``
Parameters
==========
df: DataFrame
items: dict
mapping of columns to dtype.
Returns
=======
df : DataFrame
"""
dtypes = df.dtypes
for k, v in items.items():
if not dtypes[k] == v:
raise AssertionError("{} has the wrong dtype. Should be ({}), is ({})".format(k, v,dtypes[k]))
return df
def one_to_many(df, unitcol, manycol):
"""
Assert that a many-to-one relationship is preserved between two
columns. For example, a retail store will have have distinct
departments, each with several employees. If each employee may
only work in a single department, then the relationship of the
department to the employees is one to many.
Parameters
==========
df : DataFrame
unitcol : str
The column that encapulates the groups in ``manycol``.
manycol : str
The column that must remain unique in the distict pairs
between ``manycol`` and ``unitcol``
Returns
=======
df : DataFrame
"""
subset = df[[manycol, unitcol]].drop_duplicates()
for many in subset[manycol].unique():
if subset[subset[manycol] == many].shape[0] > 1:
msg = "{} in {} has multiple values for {}".format(many, manycol, unitcol)
raise AssertionError(msg)
return df
def is_same_as(df, df_to_compare, **kwargs):
"""
Assert that two pandas dataframes are the equal
Parameters
==========
df : pandas DataFrame
df_to_compare : pandas DataFrame
**kwargs : dict
keyword arguments passed through to panda's ``assert_frame_equal``
Returns
=======
df : DataFrame
"""
try:
tm.assert_frame_equal(df, df_to_compare, **kwargs)
except AssertionError as exc:
six.raise_from(AssertionError("DataFrames are not equal"), exc)
return df
__all__ = ['is_monotonic', 'is_same_as', 'is_shape', 'none_missing',
'unique_index', 'within_n_std', 'within_range', 'within_set',
'has_dtypes', 'verify', 'verify_all', 'verify_any',
'one_to_many','is_same_as',]
|
{
"content_hash": "464125b34b142ddc3a00b404674b036d",
"timestamp": "",
"source": "github",
"line_count": 300,
"max_line_length": 106,
"avg_line_length": 25.09,
"alnum_prop": 0.5674239404809353,
"repo_name": "TomAugspurger/engarde",
"id": "bed82816c04433e3a9c835906267b208b4bd06d4",
"size": "7551",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "engarde/checks.py",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "Batchfile",
"bytes": "236"
},
{
"name": "Python",
"bytes": "105508"
},
{
"name": "Shell",
"bytes": "219"
}
]
}
|
MAKEFLAGS=-r
# The source directory tree.
srcdir := ..
abs_srcdir := $(abspath $(srcdir))
# The name of the builddir.
builddir_name ?= .
# The V=1 flag on command line makes us verbosely print command lines.
ifdef V
quiet=
else
quiet=quiet_
endif
# Specify BUILDTYPE=Release on the command line for a release build.
BUILDTYPE ?= Release
# Directory all our build output goes into.
# Note that this must be two directories beneath src/ for unit tests to pass,
# as they reach into the src/ directory for data with relative paths.
builddir ?= $(builddir_name)/$(BUILDTYPE)
abs_builddir := $(abspath $(builddir))
depsdir := $(builddir)/.deps
# Object output directory.
obj := $(builddir)/obj
abs_obj := $(abspath $(obj))
# We build up a list of every single one of the targets so we can slurp in the
# generated dependency rule Makefiles in one pass.
all_deps :=
CC.target ?= $(CC)
CFLAGS.target ?= $(CFLAGS)
CXX.target ?= $(CXX)
CXXFLAGS.target ?= $(CXXFLAGS)
LINK.target ?= $(LINK)
LDFLAGS.target ?= $(LDFLAGS)
AR.target ?= $(AR)
# C++ apps need to be linked with g++.
#
# Note: flock is used to seralize linking. Linking is a memory-intensive
# process so running parallel links can often lead to thrashing. To disable
# the serialization, override LINK via an envrionment variable as follows:
#
# export LINK=g++
#
# This will allow make to invoke N linker processes as specified in -jN.
LINK ?= ./gyp-mac-tool flock $(builddir)/linker.lock $(CXX.target)
# TODO(evan): move all cross-compilation logic to gyp-time so we don't need
# to replicate this environment fallback in make as well.
CC.host ?= gcc
CFLAGS.host ?=
CXX.host ?= g++
CXXFLAGS.host ?=
LINK.host ?= $(CXX.host)
LDFLAGS.host ?=
AR.host ?= ar
# Define a dir function that can handle spaces.
# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions
# "leading spaces cannot appear in the text of the first argument as written.
# These characters can be put into the argument value by variable substitution."
empty :=
space := $(empty) $(empty)
# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces
replace_spaces = $(subst $(space),?,$1)
unreplace_spaces = $(subst ?,$(space),$1)
dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1)))
# Flags to make gcc output dependency info. Note that you need to be
# careful here to use the flags that ccache and distcc can understand.
# We write to a dep file on the side first and then rename at the end
# so we can't end up with a broken dep file.
depfile = $(depsdir)/$(call replace_spaces,$@).d
DEPFLAGS = -MMD -MF $(depfile).raw
# We have to fixup the deps output in a few ways.
# (1) the file output should mention the proper .o file.
# ccache or distcc lose the path to the target, so we convert a rule of
# the form:
# foobar.o: DEP1 DEP2
# into
# path/to/foobar.o: DEP1 DEP2
# (2) we want missing files not to cause us to fail to build.
# We want to rewrite
# foobar.o: DEP1 DEP2 \
# DEP3
# to
# DEP1:
# DEP2:
# DEP3:
# so if the files are missing, they're just considered phony rules.
# We have to do some pretty insane escaping to get those backslashes
# and dollar signs past make, the shell, and sed at the same time.
# Doesn't work with spaces, but that's fine: .d files have spaces in
# their names replaced with other characters.
define fixup_dep
# The depfile may not exist if the input file didn't have any #includes.
touch $(depfile).raw
# Fixup path as in (1).
sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile)
# Add extra rules as in (2).
# We remove slashes and replace spaces with new lines;
# remove blank lines;
# delete the first line and append a colon to the remaining lines.
sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
grep -v '^$$' |\
sed -e 1d -e 's|$$|:|' \
>> $(depfile)
rm $(depfile).raw
endef
# Command definitions:
# - cmd_foo is the actual command to run;
# - quiet_cmd_foo is the brief-output summary of the command.
quiet_cmd_cc = CC($(TOOLSET)) $@
cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_cxx = CXX($(TOOLSET)) $@
cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_objc = CXX($(TOOLSET)) $@
cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
quiet_cmd_objcxx = CXX($(TOOLSET)) $@
cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
# Commands for precompiled header files.
quiet_cmd_pch_c = CXX($(TOOLSET)) $@
cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_pch_cc = CXX($(TOOLSET)) $@
cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $<
quiet_cmd_pch_m = CXX($(TOOLSET)) $@
cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $<
quiet_cmd_pch_mm = CXX($(TOOLSET)) $@
cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $<
# gyp-mac-tool is written next to the root Makefile by gyp.
# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd
# already.
quiet_cmd_mac_tool = MACTOOL $(4) $<
cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@"
quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@
cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4)
quiet_cmd_infoplist = INFOPLIST $@
cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@"
quiet_cmd_touch = TOUCH $@
cmd_touch = touch $@
quiet_cmd_copy = COPY $@
# send stderr to /dev/null to ignore messages when linking directories.
cmd_copy = rm -rf "$@" && cp -af "$<" "$@"
quiet_cmd_alink = LIBTOOL-STATIC $@
cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^)
quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
quiet_cmd_solink = SOLINK($(TOOLSET)) $@
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS)
quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS)
# Define an escape_quotes function to escape single quotes.
# This allows us to handle quotes properly as long as we always use
# use single quotes and escape_quotes.
escape_quotes = $(subst ','\'',$(1))
# This comment is here just to include a ' to unconfuse syntax highlighting.
# Define an escape_vars function to escape '$' variable syntax.
# This allows us to read/write command lines with shell variables (e.g.
# $LD_LIBRARY_PATH), without triggering make substitution.
escape_vars = $(subst $$,$$$$,$(1))
# Helper that expands to a shell command to echo a string exactly as it is in
# make. This uses printf instead of echo because printf's behaviour with respect
# to escape sequences is more portable than echo's across different shells
# (e.g., dash, bash).
exact_echo = printf '%s\n' '$(call escape_quotes,$(1))'
# Helper to compare the command we're about to run against the command
# we logged the last time we ran the command. Produces an empty
# string (false) when the commands match.
# Tricky point: Make has no string-equality test function.
# The kernel uses the following, but it seems like it would have false
# positives, where one string reordered its arguments.
# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
# $(filter-out $(cmd_$@), $(cmd_$(1))))
# We instead substitute each for the empty string into the other, and
# say they're equal if both substitutions produce the empty string.
# .d files contain ? instead of spaces, take that into account.
command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\
$(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1))))
# Helper that is non-empty when a prerequisite changes.
# Normally make does this implicitly, but we force rules to always run
# so we can check their command lines.
# $? -- new prerequisites
# $| -- order-only dependencies
prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?))
# Helper that executes all postbuilds until one fails.
define do_postbuilds
@E=0;\
for p in $(POSTBUILDS); do\
eval $$p;\
E=$$?;\
if [ $$E -ne 0 ]; then\
break;\
fi;\
done;\
if [ $$E -ne 0 ]; then\
rm -rf "$@";\
exit $$E;\
fi
endef
# do_cmd: run a command via the above cmd_foo names, if necessary.
# Should always run for a given target to handle command-line changes.
# Second argument, if non-zero, makes it do asm/C/C++ dependency munging.
# Third argument, if non-zero, makes it do POSTBUILDS processing.
# Note: We intentionally do NOT call dirx for depfile, since it contains ? for
# spaces already and dirx strips the ? characters.
define do_cmd
$(if $(or $(command_changed),$(prereq_changed)),
@$(call exact_echo, $($(quiet)cmd_$(1)))
@mkdir -p "$(call dirx,$@)" "$(dir $(depfile))"
$(if $(findstring flock,$(word 2,$(cmd_$1))),
@$(cmd_$(1))
@echo " $(quiet_cmd_$(1)): Finished",
@$(cmd_$(1))
)
@$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile)
@$(if $(2),$(fixup_dep))
$(if $(and $(3), $(POSTBUILDS)),
$(call do_postbuilds)
)
)
endef
# Declare the "all" target first so it is the default,
# even though we don't have the deps yet.
.PHONY: all
all:
# make looks for ways to re-generate included makefiles, but in our case, we
# don't have a direct way. Explicitly telling make that it has nothing to do
# for them makes it go faster.
%.d: ;
# Use FORCE_DO_CMD to force a target to run. Should be coupled with
# do_cmd.
.PHONY: FORCE_DO_CMD
FORCE_DO_CMD:
TOOLSET := target
# Suffix rules, putting all outputs into $(obj).
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD
@$(call do_cmd,objc,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD
@$(call do_cmd,objcxx,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
# Try building from generated source, too.
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD
@$(call do_cmd,objc,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD
@$(call do_cmd,objcxx,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD
@$(call do_cmd,cxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD
@$(call do_cmd,objc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD
@$(call do_cmd,objcxx,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD
@$(call do_cmd,cc,1)
$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD
@$(call do_cmd,cc,1)
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
$(findstring $(join ^,$(prefix)),\
$(join ^,bufferutil.target.mk)))),)
include bufferutil.target.mk
endif
ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
$(findstring $(join ^,$(prefix)),\
$(join ^,validation.target.mk)))),)
include validation.target.mk
endif
quiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/cnoh/Desktop/material-start/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build/config.gypi -I/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/cnoh/.node-gyp/0.10.25/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/cnoh/.node-gyp/0.10.25" "-Dmodule_root_dir=/Users/cnoh/Desktop/material-start/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws" binding.gyp
Makefile: $(srcdir)/../../../../../../../../../../.node-gyp/0.10.25/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../../../../../../../../../usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi
$(call do_cmd,regen_makefile)
# "all" is a concatenation of the "all" targets from all the included
# sub-makefiles. This is just here to clarify.
all:
# Add in dependency-tracking rules. $(all_deps) is the list of every single
# target in our tree. Only consider the ones with .d (dependency) info:
d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d))
ifneq ($(d_files),)
include $(d_files)
endif
|
{
"content_hash": "ed72256ea4dee64b46f2d0391b4d7bd4",
"timestamp": "",
"source": "github",
"line_count": 349,
"max_line_length": 714,
"avg_line_length": 38.92836676217765,
"alnum_prop": 0.6519947004269101,
"repo_name": "cnoh/Covalence-WebApp",
"id": "8e0de583ae1760e466b70e1410329b3c243303d5",
"size": "13916",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/build/Makefile",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "CSS",
"bytes": "46528"
},
{
"name": "HTML",
"bytes": "856226"
},
{
"name": "JavaScript",
"bytes": "1915818"
},
{
"name": "PHP",
"bytes": "3338"
}
]
}
|
'use strict';
const sessions = require('../fixtures/sessions');
const users = require('../fixtures/users');
process.env.NODE_ENV = 'test';
process.env.MONGO_DB = 'test';
delete process.env.MONGO_URI;
process.env.APP_ADMINS = 'Foo,Bar';
process.env.APP_SECRET = 'foobar';
process.env.SLACK_WEBHOOK_URI = 'https://localhost/foo/bar';
process.env.USER_NO_PROFILE_COOKIE = sessions[0].cookie;
process.env.USER_NO_PROFILE_OWNER = users[0].userName;
process.env.USER_INVALID_PROFILE_COOKIE = sessions[1].cookie;
process.env.USER_INVALID_PROFILE_OWNER = users[1].userName;
process.env.USER_WITH_APPS_COOKIE = sessions[2].cookie;
process.env.USER_WITH_APPS_OWNER = users[2].userName;
process.env.USER_NO_APPS_COOKIE = sessions[3].cookie;
process.env.USER_NO_APPS_OWNER = users[3].userName;
|
{
"content_hash": "d6b4c92413d69496605a869b8bf27af6",
"timestamp": "",
"source": "github",
"line_count": 25,
"max_line_length": 61,
"avg_line_length": 31.6,
"alnum_prop": 0.7367088607594937,
"repo_name": "Turbasen/Developer",
"id": "19c006b31fe9f6ad7352bf2c8bbf6e12231845de",
"size": "790",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "test/support/env.js",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "CSS",
"bytes": "465"
},
{
"name": "HTML",
"bytes": "31985"
},
{
"name": "JavaScript",
"bytes": "71134"
}
]
}
|
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## [Unreleased]
### Changed
- Add a new arity to `make-widget-async` to provide a different widget shape.
## [0.1.1] - 2017-02-21
### Changed
- Documentation on how to make the widgets.
### Removed
- `make-widget-sync` - we're all async, all the time.
### Fixed
- Fixed widget maker to keep working when daylight savings switches over.
## 0.1.0 - 2017-02-21
### Added
- Files from the new template.
- Widget maker public API - `make-widget-sync`.
[Unreleased]: https://github.com/your-name/org-parser/compare/0.1.1...HEAD
[0.1.1]: https://github.com/your-name/org-parser/compare/0.1.0...0.1.1
|
{
"content_hash": "32d199a3eb7adb11c47caebc872ae97a",
"timestamp": "",
"source": "github",
"line_count": 23,
"max_line_length": 161,
"avg_line_length": 33.08695652173913,
"alnum_prop": 0.7109067017082786,
"repo_name": "JonathanHope/org-parser",
"id": "6576750c34415aa39b21b7a9dc53e93b6f6de62b",
"size": "774",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "CHANGELOG.md",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "Clojure",
"bytes": "15742"
}
]
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration.Provider;
namespace Nettiers.AdventureWorks.Data.Bases
{
/// <summary>
/// Reprensents the strongly typed collection of NetTiersProvider.
/// </summary>
public class NetTiersProviderCollection : ProviderCollection
{
/// <summary>
/// Gets the <see cref="T:NetTiersProvider"/> with the specified name.
/// </summary>
/// <value></value>
public new NetTiersProvider this[string name]
{
get { return (NetTiersProvider)base[name]; }
}
/// <summary>
/// Adds the specified provider.
/// </summary>
/// <param name="provider">The provider.</param>
public void Add(NetTiersProvider provider)
{
if (provider == null)
{
throw new ArgumentNullException("provider");
}
if (!(provider is NetTiersProvider))
{
throw new ArgumentException("Invalid provider type", "provider");
}
base.Add(provider);
}
}
}
|
{
"content_hash": "3af2f6e4d3f7533676d66663451d28eb",
"timestamp": "",
"source": "github",
"line_count": 40,
"max_line_length": 78,
"avg_line_length": 27.45,
"alnum_prop": 0.5938069216757741,
"repo_name": "Giten2004/netTiers",
"id": "acf2bda4991dc735df90eb4bc89489dede369164",
"size": "1100",
"binary": false,
"copies": "2",
"ref": "refs/heads/master",
"path": "Samples/AdventureWorks/Generated/Nettiers.AdventureWorks.Data/Bases/NetTiersProviderCollection.cs",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "ASP",
"bytes": "620"
},
{
"name": "C#",
"bytes": "331739"
},
{
"name": "CSS",
"bytes": "9299"
},
{
"name": "JavaScript",
"bytes": "18312"
},
{
"name": "XSLT",
"bytes": "25193"
}
]
}
|
import unittest
from mock.mock import MagicMock
from asciimatics.particles import ShootScreen, DropScreen, Explosion, Rain, \
StarFirework, PalmFirework, RingFirework, SerpentFirework
from asciimatics.screen import Screen, Canvas
class TestParticles(unittest.TestCase):
def check_effect(self, canvas, effect, assert_fn,
is_blank=True, iterations=40, warm_up=0):
"""
Basic checks for all effects. Since they are all randomised to a
certain extent, just check the overall content for expected values.
"""
# Asciimatics always calls reset on entering a new Scene.
effect.reset()
# Check canvas is in desired starting state.
if is_blank:
for x in range(canvas.width):
for y in range(canvas.height):
self.assertEqual(canvas.get_from(x, y), (32, 7, 0, 0))
# Set up blank my_buffer - OK this should copy the existing screen, but
# we just lose one iteration on the checks (when not really blank).
my_buffer = [[(32, 7, 0, 0) for _ in range(40)] for _ in range(10)]
# Re-draw comparing the my_buffer with what's on the canvas
for i in range(iterations):
effect.update(i)
changed = False
if i >= warm_up:
view = ""
for y in range(canvas.height):
for x in range(canvas.width):
value = canvas.get_from(x, y)
assert_fn(value)
if value != my_buffer[y][x]:
changed = True
my_buffer[y][x] = value
view += chr(value[0])
view += "\n"
self.assertTrue(changed, "failed at step %d %s" % (i, view))
# Check there is no stop frame by default.
self.assertEqual(effect.stop_frame, 0)
def test_shoot_screen(self):
"""
Test that ShootScreen works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
canvas.centre("Hello World!", 5)
effect = ShootScreen(canvas, canvas.width // 2, canvas.height // 2, 100)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]),
'HeloWrd! '),
is_blank=False,
iterations=4)
def test_drop_screen(self):
"""
Test that DropScreen works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
canvas.centre("Hello World!", 0)
effect = DropScreen(canvas, 100)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]),
'HeloWrd! '),
is_blank=False,
warm_up=3,
iterations=10)
def test_explosion(self):
"""
Test that Explosion works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
effect = Explosion(canvas, 4, 4, 25)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]), ' #'),
iterations=25)
def test_rain(self):
"""
Test that Rain works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
effect = Rain(canvas, 200)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]), ' `\\v'))
def test_star_firework(self):
"""
Test that StarFirework works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
effect = StarFirework(canvas, 4, 4, 25)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]), '|+:,. '),
iterations=25)
def test_palm_firework(self):
"""
Test that PalmFirework works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
effect = PalmFirework(canvas, 4, 4, 25)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]), '|*+:,. '),
iterations=26)
def test_ring_firework(self):
"""
Test that RingFirework works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
effect = RingFirework(canvas, 4, 4, 25)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]), '|*:. '),
iterations=15)
def test_serpent_firework(self):
"""
Test that SerpentFirework works as expected.
"""
screen = MagicMock(spec=Screen, colours=8)
canvas = Canvas(screen, 10, 40, 0, 0)
effect = SerpentFirework(canvas, 4, 4, 25)
self.check_effect(canvas,
effect,
lambda value: self.assertIn(chr(value[0]), '|+- '),
iterations=20)
if __name__ == '__main__':
unittest.main()
|
{
"content_hash": "3368eb1081ced73c50015a5ceb3fad43",
"timestamp": "",
"source": "github",
"line_count": 152,
"max_line_length": 80,
"avg_line_length": 38.0921052631579,
"alnum_prop": 0.4968911917098446,
"repo_name": "peterbrittain/asciimatics",
"id": "ff88cd6e26b30d8dd79f3008b3958ac99a645f46",
"size": "5790",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "tests/test_particles.py",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "Batchfile",
"bytes": "47"
},
{
"name": "Python",
"bytes": "757357"
},
{
"name": "Shell",
"bytes": "118"
}
]
}
|
import { buildConfig } from '../src/config';
test('buildConfig() builds configuration and applies env var overrides', () => {
let config = buildConfig();
expect(config.jwtSecret).toEqual(
'test123-test123-test123-test123-test123-test123-test123',
);
expect(config.redis.host).toEqual('127.0.0.1');
expect(config.redis.port).toEqual(6379);
expect(config.redis.password).toEqual('');
expect(config.redis.db).toEqual(10);
expect(config.redis.ssl).toEqual(false);
expect(config.statsd.host).toEqual('127.0.0.1');
expect(config.statsd.port).toEqual(8125);
expect(config.statsd.globalTags).toEqual([]);
process.env.JWT_SECRET = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
process.env.REDIS_HOST = '10.10.10.10';
process.env.REDIS_PORT = '6380';
process.env.REDIS_PASSWORD = 'admin';
process.env.REDIS_DB = '4';
process.env.REDIS_SSL = 'true';
process.env.STATSD_HOST = '15.15.15.15';
process.env.STATSD_PORT = '8000';
process.env.STATSD_GLOBAL_TAGS = 'tag-1,tag-2';
config = buildConfig();
expect(config.jwtSecret).toEqual('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
expect(config.redis.host).toEqual('10.10.10.10');
expect(config.redis.port).toEqual(6380);
expect(config.redis.password).toEqual('admin');
expect(config.redis.db).toEqual(4);
expect(config.redis.ssl).toEqual(true);
expect(config.statsd.host).toEqual('15.15.15.15');
expect(config.statsd.port).toEqual(8000);
expect(config.statsd.globalTags).toEqual(['tag-1', 'tag-2']);
delete process.env.JWT_SECRET;
delete process.env.REDIS_HOST;
delete process.env.REDIS_PORT;
delete process.env.REDIS_PASSWORD;
delete process.env.REDIS_DB;
delete process.env.REDIS_SSL;
delete process.env.STATSD_HOST;
delete process.env.STATSD_PORT;
delete process.env.STATSD_GLOBAL_TAGS;
});
|
{
"content_hash": "b7c2336ce009b1dd6f92cfdc6ae311de",
"timestamp": "",
"source": "github",
"line_count": 50,
"max_line_length": 80,
"avg_line_length": 35.98,
"alnum_prop": 0.717065036131184,
"repo_name": "zhouyao1994/incubator-superset",
"id": "72e592dfde8857501b819deb8170ef972c59ea6f",
"size": "2607",
"binary": false,
"copies": "5",
"ref": "refs/heads/master",
"path": "superset-websocket/spec/config.test.ts",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "CSS",
"bytes": "4776"
},
{
"name": "Dockerfile",
"bytes": "6940"
},
{
"name": "HTML",
"bytes": "1243911"
},
{
"name": "JavaScript",
"bytes": "2445349"
},
{
"name": "Jinja",
"bytes": "5542"
},
{
"name": "Jupyter Notebook",
"bytes": "1925627"
},
{
"name": "Less",
"bytes": "106438"
},
{
"name": "Makefile",
"bytes": "3946"
},
{
"name": "Mako",
"bytes": "1197"
},
{
"name": "Pug",
"bytes": "2969"
},
{
"name": "Python",
"bytes": "6296253"
},
{
"name": "Shell",
"bytes": "56211"
},
{
"name": "Smarty",
"bytes": "4298"
},
{
"name": "TypeScript",
"bytes": "6909337"
}
]
}
|
require "rails_helper"
describe "router" do
it "routes admin root" do
expect(get: "/en/admin").to route_to(
controller: "welcome", action: "index", locale: "en", mode: "admin", mission_name: nil
)
end
it "doesnt route admin root without locale" do
expect(get: "/admin").not_to be_routable
end
it "routes missions index" do
expect(get: "/en/admin/missions").to route_to(
controller: "missions", action: "index", locale: "en", mode: "admin", mission_name: nil
)
end
it "rejects missions index in mission mode" do
expect(get: "/en/m/mission123/missions").not_to be_routable
end
it "rejects mission id in admin mode" do
expect(get: "/en/admin/mission123/missions").not_to be_routable
end
end
|
{
"content_hash": "fb073eb37ff29ea88d03272a57330273",
"timestamp": "",
"source": "github",
"line_count": 27,
"max_line_length": 93,
"avg_line_length": 27.88888888888889,
"alnum_prop": 0.6626826029216467,
"repo_name": "thecartercenter/elmo",
"id": "8811476b386b2c6e796d90715452823a8930e6ce",
"size": "784",
"binary": false,
"copies": "1",
"ref": "refs/heads/12085_prevent_dupes",
"path": "spec/routing/admin_routes_spec.rb",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "CSS",
"bytes": "97107"
},
{
"name": "CoffeeScript",
"bytes": "57714"
},
{
"name": "HTML",
"bytes": "144925"
},
{
"name": "JavaScript",
"bytes": "194066"
},
{
"name": "Ruby",
"bytes": "1756251"
}
]
}
|
goog.require('shaka.dash.MpdUtils');
goog.require('shaka.dash.mpd');
describe('MpdUtils', function() {
// Alias.
var MpdUtils = shaka.dash.MpdUtils;
beforeAll(function() {
// Hijack assertions and convert failed assertions into failed tests.
assertsToFailures.install();
});
afterAll(function() {
assertsToFailures.uninstall();
});
describe('fillUrlTemplate', function() {
it('handles a single RepresentationID identifier', function() {
expect(
MpdUtils.fillUrlTemplate(
'/example/$RepresentationID$.mp4',
100, null, null, null).toString()).toBe('/example/100.mp4');
// RepresentationID cannot use a width specifier.
expect(
MpdUtils.fillUrlTemplate(
'/example/$RepresentationID%01d$.mp4',
100, null, null, null).toString()).toBe('/example/100.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$RepresentationID$.mp4',
null, null, null, null).toString())
.toBe('/example/$RepresentationID$.mp4');
});
it('handles a single Number identifier', function() {
expect(
MpdUtils.fillUrlTemplate(
'/example/$Number$.mp4',
null, 100, null, null).toString()).toBe('/example/100.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$Number%05d$.mp4',
null, 100, null, null).toString()).toBe('/example/00100.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$Number$.mp4',
null, null, null, null).toString())
.toBe('/example/$Number$.mp4');
});
it('handles a single Bandwidth identifier', function() {
expect(
MpdUtils.fillUrlTemplate(
'/example/$Bandwidth$.mp4',
null, null, 100, null).toString()).toBe('/example/100.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$Bandwidth%05d$.mp4',
null, null, 100, null).toString()).toBe('/example/00100.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$Bandwidth$.mp4',
null, null, null, null).toString())
.toBe('/example/$Bandwidth$.mp4');
});
it('handles a single Time identifier', function() {
expect(
MpdUtils.fillUrlTemplate(
'/example/$Time$.mp4',
null, null, null, 100).toString()).toBe('/example/100.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$Time%05d$.mp4',
null, null, null, 100).toString()).toBe('/example/00100.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$Time$.mp4',
null, null, null, null).toString())
.toBe('/example/$Time$.mp4');
});
it('handles multiple identifiers', function() {
expect(
MpdUtils.fillUrlTemplate(
'/example/$RepresentationID$_$Number$_$Bandwidth$_$Time$.mp4',
1, 2, 3, 4).toString()).toBe('/example/1_2_3_4.mp4');
// No spaces.
expect(
MpdUtils.fillUrlTemplate(
'/example/$RepresentationID$$Number$$Bandwidth$$Time$.mp4',
1, 2, 3, 4).toString()).toBe('/example/1234.mp4');
// Different order.
expect(
MpdUtils.fillUrlTemplate(
'/example/$Bandwidth$_$Time$_$RepresentationID$_$Number$.mp4',
1, 2, 3, 4).toString()).toBe('/example/3_4_1_2.mp4');
// Single width.
expect(
MpdUtils.fillUrlTemplate(
'$RepresentationID$_$Number%01d$_$Bandwidth%01d$_$Time%01d$',
1, 2, 3, 400).toString()).toBe('1_2_3_400');
// Different widths.
expect(
MpdUtils.fillUrlTemplate(
'$RepresentationID$_$Number%02d$_$Bandwidth%02d$_$Time%02d$',
1, 2, 3, 4).toString()).toBe('1_02_03_04');
// Double $$.
expect(
MpdUtils.fillUrlTemplate(
'$$/$RepresentationID$$$$Number$$$$Bandwidth$$$$Time$$$.$$',
1, 2, 3, 4).toString()).toBe('$/1$2$3$4$.$');
});
it('handles invalid identifiers', function() {
expect(
MpdUtils.fillUrlTemplate(
'/example/$Garbage$.mp4',
1, 2, 3, 4).toString()).toBe('/example/$Garbage$.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$RepresentationID%$',
1, 2, 3, 4)).toBeNull();
});
it('handles partial identifiers', function() {
expect(
MpdUtils.fillUrlTemplate(
'/example/$Time.mp4',
1, 2, 3, 4).toString()).toBe('/example/$Time.mp4');
expect(
MpdUtils.fillUrlTemplate(
'/example/$Time%.mp4',
1, 2, 3, 4)).toBeNull();
});
});
describe('createTimeline', function() {
it('works in normal case', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(10, 10, 0),
createTimepoint(20, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 30 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles null start time', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(null, 10, 0),
createTimepoint(null, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 30 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles gaps', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(15, 10, 0)
];
var result = [
{ start: 0, end: 15 },
{ start: 15, end: 25 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles overlap', function() {
var timepoints = [
createTimepoint(0, 15, 0),
createTimepoint(10, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles repetitions', function() {
var timepoints = [
createTimepoint(0, 10, 5),
createTimepoint(60, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 30 },
{ start: 30, end: 40 },
{ start: 40, end: 50 },
{ start: 50, end: 60 },
{ start: 60, end: 70 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles null repeat', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(10, 10, null),
createTimepoint(20, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 30 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles repetitions with gap', function() {
var timepoints = [
createTimepoint(0, 10, 2),
createTimepoint(35, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 35 },
{ start: 35, end: 45 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles negative repetitions', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(10, 10, -1),
createTimepoint(40, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 30 },
{ start: 30, end: 40 },
{ start: 40, end: 50 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles negative repetitions with uneven border', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(10, 10, -1),
createTimepoint(45, 5, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 },
{ start: 20, end: 30 },
{ start: 30, end: 40 },
{ start: 40, end: 45 },
{ start: 45, end: 50 }
];
checkTimepoints(timepoints, result, 1, 0);
});
it('handles negative repetitions at end', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(10, 5, -1)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 15 },
{ start: 15, end: 20 },
{ start: 20, end: 25 }
];
checkTimepoints(timepoints, result, 1, 25);
});
it('ignores elements after null duration', function() {
var timepoints = [
createTimepoint(0, 10, 0),
createTimepoint(10, 10, 0),
createTimepoint(20, null, 0),
createTimepoint(30, 10, 0),
createTimepoint(40, 10, 0)
];
var result = [
{ start: 0, end: 10 },
{ start: 10, end: 20 }
];
checkTimepoints(timepoints, result, 1, 0);
});
/**
* Creates a new timepoint.
*
* @param {?number} start
* @param {?number} dur
* @param {?number} rep
*/
function createTimepoint(start, dur, rep) {
var ret = new shaka.dash.mpd.SegmentTimePoint();
ret.startTime = start;
ret.duration = dur;
ret.repeat = rep;
return ret;
}
/**
* Checks that the createTimeline works with the given timepoints and the
* given expected results.
*
* @param {!Array.<!shaka.dash.mpd.TimePoint>} points
* @param {!Array.<{start: number, end: number}} expected
* @param {number} scale
* @param {number} duration
*/
function checkTimepoints(points, expected, scale, duration) {
var timeline = new shaka.dash.mpd.SegmentTimeline();
timeline.timePoints = points;
var data = MpdUtils.createTimeline(timeline, scale, duration);
expect(data).toBeTruthy();
expect(data.length).toBe(expected.length);
for (var i = 0; i < expected.length; i++) {
expect(data[i].start).toBe(expected[i].start);
expect(data[i].end).toBe(expected[i].end);
}
}
});
});
|
{
"content_hash": "d93e03b011879b2e67f0d6308cb4e253",
"timestamp": "",
"source": "github",
"line_count": 353,
"max_line_length": 77,
"avg_line_length": 29.297450424929178,
"alnum_prop": 0.5190485399342487,
"repo_name": "sanbornhnewyyz/shaka-player",
"id": "7b4cf7b57593e2d359a9c3a1fc437488e433c332",
"size": "10949",
"binary": false,
"copies": "6",
"ref": "refs/heads/master",
"path": "spec/mpd_utils_spec.js",
"mode": "33188",
"license": "apache-2.0",
"language": [
{
"name": "ApacheConf",
"bytes": "135"
},
{
"name": "CSS",
"bytes": "7447"
},
{
"name": "HTML",
"bytes": "117250"
},
{
"name": "JavaScript",
"bytes": "1118833"
},
{
"name": "Python",
"bytes": "26998"
},
{
"name": "Shell",
"bytes": "12235"
}
]
}
|
Notes
-------
tsk_recover recover files to the output_dir from the image. By default recovers only unallocated files. With flags, it will export all files.
Help Text
-------
```
usage: tsk_recover [-vVae] [-f fstype] [-i imgtype] [-b dev_sector_size] [-o sector_offset] [-d dir_inum] image [image] output_dir
-i imgtype: The format of the image file (use '-i list' for supported types)
-b dev_sector_size: The size (in bytes) of the device sectors
-f fstype: The file system type (use '-f list' for supported types)
-v: verbose output to stderr
-V: Print version
-a: Recover allocated files only
-e: Recover all files (allocated and unallocated)
-o sector_offset: sector offset for a volume to recover (recovers only that volume)
-d dir_inum: Directory inum to recover from (must also specify a specific partition using -o or there must not be a volume system)
```
Example Usage
-------
To recover only unallocated files from image.dd to the recovered directory:
```
# tsk_recover ./recovered ./image.dd
```
Links
-------
|
{
"content_hash": "866dca07df3c3b5fcc53c2646e89305a",
"timestamp": "",
"source": "github",
"line_count": 30,
"max_line_length": 142,
"avg_line_length": 34.6,
"alnum_prop": 0.7129094412331407,
"repo_name": "pwnwiki/kaliwiki",
"id": "2d426eafc5e2906c3ed18f9b529889da9b19aab6",
"size": "1053",
"binary": false,
"copies": "3",
"ref": "refs/heads/gh-pages",
"path": "tools/tsk_recover.md",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "HTML",
"bytes": "1166456"
}
]
}
|
///\file
#ifndef ETL_ALGORITHM_INCLUDED
#define ETL_ALGORITHM_INCLUDED
///\defgroup algorithm algorithm
/// Including reverse engineered algorithms from C++ 0x11, 0x14, 0x17
/// Additional new variants of certain algorithms.
///\ingroup utilities
#include "platform.h"
#include "type_traits.h"
#include "iterator.h"
#include "functional.h"
#include "utility.h"
#include <stdint.h>
#include <string.h>
#include "private/minmax_push.h"
#if ETL_USING_STL
#include <algorithm>
#include <utility>
#include <iterator>
#include <functional>
#include <numeric>
#endif
namespace etl
{
// Declare prototypes of the ETL's sort functions
template <typename TIterator>
#if ETL_USING_STD_NAMESPACE
ETL_CONSTEXPR20
#else
ETL_CONSTEXPR14
#endif
void shell_sort(TIterator first, TIterator last);
template <typename TIterator, typename TCompare>
#if ETL_USING_STD_NAMESPACE
ETL_CONSTEXPR20
#else
ETL_CONSTEXPR14
#endif
void shell_sort(TIterator first, TIterator last, TCompare compare);
template <typename TIterator>
ETL_CONSTEXPR14 void insertion_sort(TIterator first, TIterator last);
template <typename TIterator, typename TCompare>
ETL_CONSTEXPR14 void insertion_sort(TIterator first, TIterator last, TCompare compare);
}
//*****************************************************************************
// Algorithms defined by the ETL
//*****************************************************************************
namespace etl
{
//***************************************************************************
// iter_swap
//***************************************************************************
template <typename TIterator1, typename TIterator2>
#if ETL_USING_STD_NAMESPACE
ETL_CONSTEXPR20
#else
ETL_CONSTEXPR14
#endif
void iter_swap(TIterator1 a, TIterator2 b)
{
using ETL_OR_STD::swap; // Allow ADL
swap(*a, *b);
}
//***************************************************************************
// swap_ranges
//***************************************************************************
template <typename TIterator1, typename TIterator2>
#if ETL_USING_STD_NAMESPACE
ETL_CONSTEXPR20
#else
ETL_CONSTEXPR14
#endif
TIterator2 swap_ranges(TIterator1 first1,
TIterator1 last1,
TIterator2 first2)
{
while (first1 != last1)
{
iter_swap(first1, first2);
++first1;
++first2;
}
return first2;
}
//***************************************************************************
// copy
#if ETL_USING_STL && ETL_USING_CPP20
// Use the STL constexpr implementation.
template <typename TIterator1, typename TIterator2>
constexpr TIterator2 copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{
return std::copy(sb, se, db);
}
#else
// Non-pointer or not trivially copyable or not using builtin memcpy.
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{
while (sb != se)
{
*db = *sb;
++db;
++sb;
}
return db;
}
#endif
//***************************************************************************
// reverse_copy
#if ETL_USING_STL && ETL_USING_CPP20
template <typename TIterator1, typename TIterator2>
constexpr TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{
return std::reverse_copy(sb, se, db);
}
#else
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14
TIterator2 reverse_copy(TIterator1 sb, TIterator1 se, TIterator2 db)
{
while (sb != se)
{
*db = *--se;
++db;
}
return db;
}
#endif
//***************************************************************************
// copy_n
#if ETL_USING_STL && ETL_USING_CPP20
// Use the STL implementation
template <typename TIterator1, typename TSize, typename TIterator2>
constexpr TIterator2 copy_n(TIterator1 sb, TSize count, TIterator2 db)
{
return std::copy_n(sb, count, db);
}
#else
// Non-pointer or not trivially copyable or not using builtin memcpy.
template <typename TIterator1, typename TSize, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 copy_n(TIterator1 sb, TSize count, TIterator2 db)
{
while (count != 0)
{
*db = *sb;
++db;
++sb;
--count;
}
return db;
}
#endif
//***************************************************************************
// copy_backward
#if ETL_USING_STL && ETL_USING_CPP20
template <typename TIterator1, typename TIterator2>
constexpr TIterator2 copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
return std::copy_backward(sb, se, de);
}
#else
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 copy_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
while (se != sb)
{
*(--de) = *(--se);
}
return de;
}
#endif
//***************************************************************************
// move
#if ETL_USING_STL && ETL_USING_CPP20
template <typename TIterator1, typename TIterator2>
constexpr TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
{
return std::move(sb, se, db);
}
#else
// non-pointer or not trivially copyable
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 move(TIterator1 sb, TIterator1 se, TIterator2 db)
{
while (sb != se)
{
*db = etl::move(*sb);
++db;
++sb;
}
return db;
}
#endif
//***************************************************************************
// move_backward
#if ETL_USING_STL && ETL_USING_CPP20
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR20
TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
return std::move_backward(sb, se, de);
}
#else
// non-pointer or not trivially copyable
template <typename TIterator1, typename TIterator2>
ETL_CONSTEXPR14 TIterator2 move_backward(TIterator1 sb, TIterator1 se, TIterator2 de)
{
while (sb != se)
{
*(--de) = etl::move(*(--se));
}
return de;
}
#endif
//***************************************************************************
// reverse
//***************************************************************************
// Pointers
template <typename TIterator>
typename etl::enable_if<etl::is_pointer<TIterator>::value, void>::type
reverse(TIterator b, TIterator e)
{
if (b != e)
{
while (b < --e)
{
etl::iter_swap(b, e);
++b;
}
}
}
// Non-pointers
template <typename TIterator>
typename etl::enable_if<!etl::is_pointer<TIterator>::value, void>::type
reverse(TIterator b, TIterator e)
{
while ((b != e) && (b != --e))
{
etl::iter_swap(b++, e);
}
}
//***************************************************************************
// lower_bound
//***************************************************************************
template<typename TIterator, typename TValue, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator lower_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
{
typedef typename etl::iterator_traits<TIterator>::difference_type difference_t;
difference_t count = etl::distance(first, last);
while (count > 0)
{
TIterator itr = first;
difference_t step = count / 2;
etl::advance(itr, step);
if (compare(*itr, value))
{
first = ++itr;
count -= step + 1;
}
else
{
count = step;
}
}
return first;
}
template<typename TIterator, typename TValue>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator lower_bound(TIterator first, TIterator last, const TValue& value)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
return etl::lower_bound(first, last, value, compare());
}
//***************************************************************************
// upper_bound
//***************************************************************************
template<typename TIterator, typename TValue, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator upper_bound(TIterator first, TIterator last, const TValue& value, TCompare compare)
{
typedef typename etl::iterator_traits<TIterator>::difference_type difference_t;
difference_t count = etl::distance(first, last);
while (count > 0)
{
TIterator itr = first;
difference_t step = count / 2;
etl::advance(itr, step);
if (!compare(value, *itr))
{
first = ++itr;
count -= step + 1;
}
else
{
count = step;
}
}
return first;
}
template<typename TIterator, typename TValue>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator upper_bound(TIterator first, TIterator last, const TValue& value)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
return etl::upper_bound(first, last, value, compare());
}
//***************************************************************************
// equal_range
//***************************************************************************
template<typename TIterator, typename TValue, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
ETL_OR_STD::pair<TIterator, TIterator> equal_range(TIterator first, TIterator last, const TValue& value, TCompare compare)
{
return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare),
etl::upper_bound(first, last, value, compare));
}
template<typename TIterator, typename TValue>
ETL_NODISCARD
ETL_OR_STD::pair<TIterator, TIterator> equal_range(TIterator first, TIterator last, const TValue& value)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
return ETL_OR_STD::make_pair(etl::lower_bound(first, last, value, compare()),
etl::upper_bound(first, last, value, compare()));
}
//***************************************************************************
// binary_search
//***************************************************************************
template <typename TIterator, typename T, typename Compare>
ETL_NODISCARD
bool binary_search(TIterator first, TIterator last, const T& value, Compare compare)
{
first = etl::lower_bound(first, last, value, compare);
return (!(first == last) && !(compare(value, *first)));
}
template <typename TIterator, typename T>
ETL_NODISCARD
bool binary_search(TIterator first, TIterator last, const T& value)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
return binary_search(first, last, value, compare());
}
//***************************************************************************
// find_if
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator find_if(TIterator first, TIterator last, TUnaryPredicate predicate)
{
while (first != last)
{
if (predicate(*first))
{
return first;
}
++first;
}
return last;
}
//***************************************************************************
// find
//***************************************************************************
template <typename TIterator, typename T>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator find(TIterator first, TIterator last, const T& value)
{
while (first != last)
{
if (*first == value)
{
return first;
}
++first;
}
return last;
}
//***************************************************************************
// fill
#if ETL_USING_STL && ETL_USING_CPP20
template<typename TIterator, typename TValue>
constexpr void fill(TIterator first, TIterator last, const TValue& value)
{
std::fill(first, last, value);
}
#else
template<typename TIterator, typename TValue>
ETL_CONSTEXPR14 void fill(TIterator first, TIterator last, const TValue& value)
{
while (first != last)
{
*first = value;
++first;
}
}
#endif
//***************************************************************************
// fill_n
#if ETL_USING_STL && ETL_USING_CPP20
template<typename TIterator, typename TSize, typename TValue>
constexpr TIterator fill_n(TIterator first, TSize count, const TValue& value)
{
return std::fill_n(first, count, value);
}
#else
template<typename TIterator, typename TSize, typename TValue>
ETL_CONSTEXPR14 TIterator fill_n(TIterator first, TSize count, const TValue& value)
{
while (count != 0)
{
*first++ = value;
--count;
}
return first;
}
#endif
//***************************************************************************
// count
//***************************************************************************
template <typename TIterator, typename T>
ETL_NODISCARD
ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type count(TIterator first, TIterator last, const T& value)
{
typename iterator_traits<TIterator>::difference_type n = 0;
while (first != last)
{
if (*first == value)
{
++n;
}
++first;
}
return n;
}
//***************************************************************************
// count_if
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
typename etl::iterator_traits<TIterator>::difference_type
count_if(TIterator first, TIterator last, TUnaryPredicate predicate)
{
typename iterator_traits<TIterator>::difference_type n = 0;
while (first != last)
{
if (predicate(*first))
{
++n;
}
++first;
}
return n;
}
//***************************************************************************
// equal
#if ETL_USING_STL && ETL_USING_CPP20
template <typename TIterator1, typename TIterator2>
[[nodiscard]]
constexpr
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
{
return std::equal(first1, last1, first2);
}
template <typename TIterator1, typename TIterator2, typename TPredicate>
[[nodiscard]]
constexpr
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TPredicate predicate)
{
return std::equal(first1, last1, first2, predicate);
}
#else
// Not pointer types or not trivially copyable.
template <typename TIterator1, typename TIterator2>
ETL_NODISCARD
ETL_CONSTEXPR14
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2)
{
while (first1 != last1)
{
if (*first1 != *first2)
{
return false;
}
++first1;
++first2;
}
return true;
}
// Predicate
template <typename TIterator1, typename TIterator2, typename TPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TPredicate predicate)
{
while (first1 != last1)
{
if (!predicate(*first1, *first2))
{
return false;
}
++first1;
++first2;
}
return true;
}
// Four parameter
template <typename TIterator1, typename TIterator2>
ETL_NODISCARD
ETL_CONSTEXPR14
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2)
{
while ((first1 != last1) && (first2 != last2))
{
if (*first1 != *first2)
{
return false;
}
++first1;
++first2;
}
return (first1 == last1) && (first2 == last2);
}
// Four parameter, Predicate
template <typename TIterator1, typename TIterator2, typename TPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
bool equal(TIterator1 first1, TIterator1 last1, TIterator2 first2, TIterator2 last2, TPredicate predicate)
{
while ((first1 != last1) && (first2 != last2))
{
if (!predicate(*first1 , *first2))
{
return false;
}
++first1;
++first2;
}
return (first1 == last1) && (first2 == last2);
}
#endif
//***************************************************************************
// lexicographical_compare
//***************************************************************************
template <typename TIterator1, typename TIterator2, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
TIterator2 first2, TIterator2 last2,
TCompare compare)
{
while ((first1 != last1) && (first2 != last2))
{
if (compare(*first1, *first2))
{
return true;
}
if (compare(*first2, *first1))
{
return false;
}
++first1;
++first2;
}
return (first1 == last1) && (first2 != last2);
}
// lexicographical_compare
template <typename TIterator1, typename TIterator2>
ETL_NODISCARD
ETL_CONSTEXPR14
bool lexicographical_compare(TIterator1 first1, TIterator1 last1,
TIterator2 first2, TIterator2 last2)
{
typedef etl::less<typename etl::iterator_traits<TIterator1>::value_type> compare;
return etl::lexicographical_compare(first1, last1, first2, last2, compare());
}
//***************************************************************************
// min
//***************************************************************************
template <typename T, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR
const T& min(const T& a, const T& b, TCompare compare)
{
return (compare(a, b)) ? a : b;
}
template <typename T>
ETL_NODISCARD
ETL_CONSTEXPR
const T& min(const T& a, const T& b)
{
typedef etl::less<T> compare;
return etl::min(a, b, compare());
}
//***************************************************************************
// max
//***************************************************************************
template <typename T, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR
const T& max(const T& a, const T& b, TCompare compare)
{
return (compare(a, b)) ? b : a;
}
template <typename T>
ETL_NODISCARD
ETL_CONSTEXPR
const T& max(const T& a, const T& b)
{
typedef etl::less<T> compare;
return etl::max(a, b, compare());
}
//***************************************************************************
// for_each
//***************************************************************************
template <typename TIterator, typename TUnaryOperation>
ETL_CONSTEXPR14
TUnaryOperation for_each(TIterator first, TIterator last, TUnaryOperation unary_operation)
{
while (first != last)
{
unary_operation(*first);
++first;
}
return unary_operation;
}
//***************************************************************************
// transform
//***************************************************************************
template <typename TIteratorIn, typename TIteratorOut, typename TUnaryOperation>
ETL_CONSTEXPR14
TIteratorOut transform(TIteratorIn first1, TIteratorIn last1, TIteratorOut d_first, TUnaryOperation unary_operation)
{
while (first1 != last1)
{
*d_first = unary_operation(*first1);
++d_first;
++first1;
}
return d_first;
}
template <typename TIteratorIn1, typename TIteratorIn2, typename TIteratorOut, typename TBinaryOperation>
ETL_CONSTEXPR14
TIteratorOut transform(TIteratorIn1 first1, TIteratorIn1 last1, TIteratorIn2 first2, TIteratorOut d_first, TBinaryOperation binary_operation)
{
while (first1 != last1)
{
*d_first = binary_operation(*first1, *first2);
++d_first;
++first1;
++first2;
}
return d_first;
}
//***************************************************************************
// replace
//***************************************************************************
template <typename TIterator, typename T>
ETL_CONSTEXPR14 void replace(TIterator first, TIterator last, const T& old_value, const T& new_value)
{
while (first != last)
{
if (*first == old_value)
{
*first = new_value;
}
++first;
}
}
//***************************************************************************
// replace_if
//***************************************************************************
template <typename TIterator, typename TPredicate, typename T>
ETL_CONSTEXPR14 void replace_if(TIterator first, TIterator last, TPredicate predicate, const T& new_value)
{
while (first != last)
{
if (predicate(*first))
{
*first = new_value;
}
++first;
}
}
//***************************************************************************
// Heap
//***************************************************************************
namespace private_heap
{
// Push Heap Helper
template <typename TIterator, typename TDistance, typename TValue, typename TCompare>
void push_heap(TIterator first, TDistance value_index, TDistance top_index, TValue value, TCompare compare)
{
TDistance parent = (value_index - 1) / 2;
while ((value_index > top_index) && compare(first[parent], value))
{
first[value_index] = etl::move(first[parent]);
value_index = parent;
parent = (value_index - 1) / 2;
}
first[value_index] = etl::move(value);
}
// Adjust Heap Helper
template <typename TIterator, typename TDistance, typename TValue, typename TCompare>
void adjust_heap(TIterator first, TDistance value_index, TDistance length, TValue value, TCompare compare)
{
TDistance top_index = value_index;
TDistance child2nd = (2 * value_index) + 2;
while (child2nd < length)
{
if (compare(first[child2nd], first[child2nd - 1]))
{
--child2nd;
}
first[value_index] = etl::move(first[child2nd]);
value_index = child2nd;
child2nd = 2 * (child2nd + 1);
}
if (child2nd == length)
{
first[value_index] = etl::move(first[child2nd - 1]);
value_index = child2nd - 1;
}
push_heap(first, value_index, top_index, etl::move(value), compare);
}
// Is Heap Helper
template <typename TIterator, typename TDistance, typename TCompare>
bool is_heap(const TIterator first, const TDistance n, TCompare compare)
{
TDistance parent = 0;
for (TDistance child = 1; child < n; ++child)
{
if (compare(first[parent], first[child]))
{
return false;
}
if ((child & 1) == 0)
{
++parent;
}
}
return true;
}
}
// Pop Heap
template <typename TIterator, typename TCompare>
void pop_heap(TIterator first, TIterator last, TCompare compare)
{
typedef typename etl::iterator_traits<TIterator>::value_type value_t;
typedef typename etl::iterator_traits<TIterator>::difference_type distance_t;
value_t value = etl::move(last[-1]);
last[-1] = etl::move(first[0]);
private_heap::adjust_heap(first, distance_t(0), distance_t(last - first - 1), etl::move(value), compare);
}
// Pop Heap
template <typename TIterator>
void pop_heap(TIterator first, TIterator last)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
etl::pop_heap(first, last, compare());
}
// Push Heap
template <typename TIterator, typename TCompare>
void push_heap(TIterator first, TIterator last, TCompare compare)
{
typedef typename etl::iterator_traits<TIterator>::difference_type difference_t;
typedef typename etl::iterator_traits<TIterator>::value_type value_t;
private_heap::push_heap(first, difference_t(last - first - 1), difference_t(0), value_t(etl::move(*(last - 1))), compare);
}
// Push Heap
template <typename TIterator>
void push_heap(TIterator first, TIterator last)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
etl::push_heap(first, last, compare());
}
// Make Heap
template <typename TIterator, typename TCompare>
void make_heap(TIterator first, TIterator last, TCompare compare)
{
typedef typename etl::iterator_traits<TIterator>::difference_type difference_t;
if ((last - first) < 2)
{
return;
}
difference_t length = last - first;
difference_t parent = (length - 2) / 2;
while (true)
{
private_heap::adjust_heap(first, parent, length, etl::move(*(first + parent)), compare);
if (parent == 0)
{
return;
}
--parent;
}
}
// Make Heap
template <typename TIterator>
void make_heap(TIterator first, TIterator last)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
etl::make_heap(first, last, compare());
}
// Is Heap
template <typename TIterator>
ETL_NODISCARD
bool is_heap(TIterator first, TIterator last)
{
typedef etl::less<typename etl::iterator_traits<TIterator>::value_type> compare;
return private_heap::is_heap(first, last - first, compare());
}
// Is Heap
template <typename TIterator, typename TCompare>
ETL_NODISCARD
bool is_heap(TIterator first, TIterator last, TCompare compare)
{
return private_heap::is_heap(first, last - first, compare);
}
// Sort Heap
template <typename TIterator>
void sort_heap(TIterator first, TIterator last)
{
while (first != last)
{
etl::pop_heap(first, last);
--last;
}
}
// Sort Heap
template <typename TIterator, typename TCompare>
void sort_heap(TIterator first, TIterator last, TCompare compare)
{
while (first != last)
{
etl::pop_heap(first, last, compare);
--last;
}
}
//***************************************************************************
// Search
//***************************************************************************
template<typename TIterator1, typename TIterator2, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last, TCompare compare)
{
while (true)
{
TIterator1 itr = first;
TIterator2 search_itr = search_first;
while (true)
{
if (search_itr == search_last)
{
return first;
}
if (itr == last)
{
return last;
}
if (!compare(*itr, *search_itr))
{
break;
}
++itr;
++search_itr;
}
++first;
}
}
// Search
template<typename TIterator1, typename TIterator2>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator1 search(TIterator1 first, TIterator1 last, TIterator2 search_first, TIterator2 search_last)
{
typedef etl::equal_to<typename etl::iterator_traits<TIterator1>::value_type> compare;
return etl::search(first, last, search_first, search_last, compare());
}
//***************************************************************************
// Rotate
//***************************************************************************
namespace private_algorithm
{
//*********************************
template <typename TIterator>
ETL_CONSTEXPR14
TIterator rotate_general(TIterator first, TIterator middle, TIterator last)
{
TIterator next = middle;
while (first != next)
{
using ETL_OR_STD::swap; // Allow ADL
swap(*first, *next);
++first;
++next;
if (next == last)
{
next = middle;
}
else if (first == middle)
{
middle = next;
}
}
return first;
}
//*********************************
template <typename TIterator>
ETL_CONSTEXPR14
TIterator rotate_left_by_one(TIterator first, TIterator last)
{
typedef typename etl::iterator_traits<TIterator>::value_type value_type;
// Save the first item.
value_type temp(etl::move(*first));
// Move the rest.
TIterator result = etl::move(etl::next(first), last, first);
// Restore the first item in its rotated position.
*result = etl::move(temp);
// The new position of the first item.
return result;
}
//*********************************
template <typename TIterator>
ETL_CONSTEXPR14
TIterator rotate_right_by_one(TIterator first, TIterator last)
{
typedef typename etl::iterator_traits<TIterator>::value_type value_type;
// Save the last item.
TIterator previous = etl::prev(last);
value_type temp(etl::move(*previous));
// Move the rest.
TIterator result = etl::move_backward(first, previous, last);
// Restore the last item in its rotated position.
*first = etl::move(temp);
// The new position of the first item.
return result;
}
}
//*********************************
template<typename TIterator>
ETL_CONSTEXPR14
TIterator rotate(TIterator first, TIterator middle, TIterator last)
{
if (etl::next(first) == middle)
{
return private_algorithm::rotate_left_by_one(first, last);
}
if (etl::next(middle) == last)
{
return private_algorithm::rotate_right_by_one(first, last);
}
return private_algorithm::rotate_general(first, middle, last);
}
//***************************************************************************
// find_end
//***************************************************************************
// Predicate
template <typename TIterator1, typename TIterator2, typename TPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator1 find_end(TIterator1 b, TIterator1 e,
TIterator2 sb, TIterator2 se,
TPredicate predicate)
{
if (sb == se)
{
return e;
}
TIterator1 result = e;
while (true)
{
TIterator1 new_result = etl::search(b, e, sb, se, predicate);
if (new_result == e)
{
break;
}
else
{
result = new_result;
b = result;
++b;
}
}
return result;
}
// Default
template <typename TIterator1, typename TIterator2>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator1 find_end(TIterator1 b, TIterator1 e,
TIterator2 sb, TIterator2 se)
{
typedef etl::equal_to<typename etl::iterator_traits<TIterator1>::value_type> predicate;
return find_end(b, e, sb, se, predicate());
}
//***************************************************************************
/// Finds the iterator to the smallest element in the range (begin, end).<br>
///<a href="http://en.cppreference.com/w/cpp/algorithm/min_element"></a>
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator min_element(TIterator begin,
TIterator end,
TCompare compare)
{
TIterator minimum = begin;
++begin;
while (begin != end)
{
if (compare(*begin, *minimum))
{
minimum = begin;
}
++begin;
}
return minimum;
}
//***************************************************************************
/// min_element
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/min_element"></a>
//***************************************************************************
template <typename TIterator>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator min_element(TIterator begin,
TIterator end)
{
typedef typename etl::iterator_traits<TIterator>::value_type value_t;
return etl::min_element(begin, end, etl::less<value_t>());
}
//***************************************************************************
/// Finds the iterator to the largest element in the range (begin, end).<br>
///<a href="http://en.cppreference.com/w/cpp/algorithm/max_element"></a>
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator max_element(TIterator begin,
TIterator end,
TCompare compare)
{
TIterator maximum = begin;
++begin;
while (begin != end)
{
if (!compare(*begin, *maximum))
{
maximum = begin;
}
++begin;
}
return maximum;
}
//***************************************************************************
/// max_element
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/max_element"></a>
//***************************************************************************
template <typename TIterator>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator max_element(TIterator begin,
TIterator end)
{
typedef typename etl::iterator_traits<TIterator>::value_type value_t;
return etl::max_element(begin, end, etl::less<value_t>());
}
//***************************************************************************
/// Finds the greatest and the smallest element in the range (begin, end).<br>
///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax_element"></a>
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
ETL_OR_STD::pair<TIterator, TIterator> minmax_element(TIterator begin,
TIterator end,
TCompare compare)
{
TIterator minimum = begin;
TIterator maximum = begin;
++begin;
while (begin != end)
{
if (compare(*begin, *minimum))
{
minimum = begin;
}
if (compare(*maximum, *begin))
{
maximum = begin;
}
++begin;
}
return ETL_OR_STD::pair<TIterator, TIterator>(minimum, maximum);
}
//***************************************************************************
/// minmax_element
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax_element"></a>
//***************************************************************************
template <typename TIterator>
ETL_NODISCARD
ETL_CONSTEXPR14
ETL_OR_STD::pair<TIterator, TIterator> minmax_element(TIterator begin,
TIterator end)
{
typedef typename etl::iterator_traits<TIterator>::value_type value_t;
return etl::minmax_element(begin, end, etl::less<value_t>());
}
//***************************************************************************
/// minmax
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax"></a>
//***************************************************************************
template <typename T>
ETL_NODISCARD
ETL_CONSTEXPR14
ETL_OR_STD::pair<const T&, const T&> minmax(const T& a,
const T& b)
{
return (b < a) ? ETL_OR_STD::pair<const T&, const T&>(b, a) : ETL_OR_STD::pair<const T&, const T&>(a, b);
}
//***************************************************************************
/// minmax
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/minmax"></a>
//***************************************************************************
template <typename T, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
ETL_OR_STD::pair<const T&, const T&> minmax(const T& a,
const T& b,
TCompare compare)
{
return compare(b, a) ? ETL_OR_STD::pair<const T&, const T&>(b, a) : ETL_OR_STD::pair<const T&, const T&>(a, b);
}
//***************************************************************************
/// is_sorted_until
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted_until"></a>
//***************************************************************************
template <typename TIterator>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator is_sorted_until(TIterator begin,
TIterator end)
{
if (begin != end)
{
TIterator next = begin;
while (++next != end)
{
if (*next < *begin)
{
return next;
}
++begin;
}
}
return end;
}
//***************************************************************************
/// is_sorted_until
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted_until"></a>
//***************************************************************************
template <typename TIterator, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator is_sorted_until(TIterator begin,
TIterator end,
TCompare compare)
{
if (begin != end)
{
TIterator next = begin;
while (++next != end)
{
if (compare(*next, *begin))
{
return next;
}
++begin;
}
}
return end;
}
//***************************************************************************
/// is_sorted
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted"></a>
//***************************************************************************
template<typename TIterator>
ETL_NODISCARD
ETL_CONSTEXPR14
bool is_sorted(TIterator begin,
TIterator end)
{
return etl::is_sorted_until(begin, end) == end;
}
//***************************************************************************
/// is_sorted
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_sorted"></a>
//***************************************************************************
template<typename TIterator, typename TCompare>
ETL_NODISCARD
ETL_CONSTEXPR14
bool is_sorted(TIterator begin,
TIterator end,
TCompare compare)
{
return etl::is_sorted_until(begin, end, compare) == end;
}
//***************************************************************************
/// find_if_not
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/find"></a>
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator find_if_not(TIterator begin,
TIterator end,
TUnaryPredicate predicate)
{
while (begin != end)
{
if (!predicate(*begin))
{
return begin;
}
++begin;
}
return end;
}
//***************************************************************************
/// is_permutation
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_permutation"></a>
//***************************************************************************
template <typename TIterator1, typename TIterator2>
ETL_NODISCARD
ETL_CONSTEXPR14
bool is_permutation(TIterator1 begin1,
TIterator1 end1,
TIterator2 begin2)
{
if (begin1 != end1)
{
TIterator2 end2 = begin2;
etl::advance(end2, etl::distance(begin1, end1));
for (TIterator1 i = begin1; i != end1; ++i)
{
if (i == etl::find(begin1, i, *i))
{
size_t n = etl::count(begin2, end2, *i);
if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
{
return false;
}
}
}
}
return true;
}
//***************************************************************************
/// is_permutation
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_permutation"></a>
//***************************************************************************
template <typename TIterator1, typename TIterator2, typename TBinaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
bool is_permutation(TIterator1 begin1,
TIterator1 end1,
TIterator2 begin2,
TBinaryPredicate predicate)
{
if (begin1 != end1)
{
TIterator2 end2 = begin2;
etl::advance(end2, etl::distance(begin1, end1));
for (TIterator1 i = begin1; i != end1; ++i)
{
if (i == etl::find_if(begin1, i, etl::bind1st(predicate, *i)))
{
size_t n = etl::count(begin2, end2, *i);
if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
{
return false;
}
}
}
}
return true;
}
//***************************************************************************
/// is_permutation
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_permutation"></a>
//***************************************************************************
template <typename TIterator1, typename TIterator2>
ETL_NODISCARD
ETL_CONSTEXPR14
bool is_permutation(TIterator1 begin1,
TIterator1 end1,
TIterator2 begin2,
TIterator2 end2)
{
if (begin1 != end1)
{
for (TIterator1 i = begin1; i != end1; ++i)
{
if (i == etl::find(begin1, i, *i))
{
size_t n = etl::count(begin2, end2, *i);
if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
{
return false;
}
}
}
}
return true;
}
//***************************************************************************
/// is_permutation
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_permutation"></a>
//***************************************************************************
template <typename TIterator1, typename TIterator2, typename TBinaryPredicate>
ETL_NODISCARD
bool is_permutation(TIterator1 begin1,
TIterator1 end1,
TIterator2 begin2,
TIterator2 end2,
TBinaryPredicate predicate)
{
if (begin1 != end1)
{
for (TIterator1 i = begin1; i != end1; ++i)
{
if (i == etl::find_if(begin1, i, etl::bind1st(predicate, *i)))
{
size_t n = etl::count(begin2, end2, *i);
if (n == 0 || size_t(etl::count(i, end1, *i)) != n)
{
return false;
}
}
}
}
return true;
}
//***************************************************************************
/// is_partitioned
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/is_partitioned"></a>
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
bool is_partitioned(TIterator begin,
TIterator end,
TUnaryPredicate predicate)
{
while (begin != end)
{
if (!predicate(*begin))
{
break;
}
++begin;
}
while (begin != end)
{
if (predicate(*begin))
{
return false;
}
++begin;
}
return true;
}
//***************************************************************************
/// partition_point
///<a href="http://en.cppreference.com/w/cpp/algorithm/partition_point"></a>
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator partition_point(TIterator begin,
TIterator end,
TUnaryPredicate predicate)
{
while (begin != end)
{
if (!predicate(*begin))
{
return begin;
}
++begin;
}
return begin;
}
//***************************************************************************
/// Copies the elements from the range (begin, end) to two different ranges
/// depending on the value returned by the predicate.<br>
///<a href="http://en.cppreference.com/w/cpp/algorithm/partition_copy"></a>
///\ingroup algorithm
//***************************************************************************
template <typename TSource, typename TDestinationTrue, typename TDestinationFalse, typename TUnaryPredicate>
ETL_CONSTEXPR14
ETL_OR_STD::pair<TDestinationTrue, TDestinationFalse> partition_copy(TSource begin,
TSource end,
TDestinationTrue destination_true,
TDestinationFalse destination_false,
TUnaryPredicate predicate)
{
while (begin != end)
{
if (predicate(*begin))
{
*destination_true = *begin;
++destination_true;
}
else
{
*destination_false = *begin;
++destination_false;
}
++begin;
}
return ETL_OR_STD::pair<TDestinationTrue, TDestinationFalse>(destination_true, destination_false);
}
//***************************************************************************
/// copy_if
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/copy"></a>
//***************************************************************************
template <typename TIterator, typename TOutputIterator, typename TUnaryPredicate>
ETL_CONSTEXPR14
TOutputIterator copy_if(TIterator begin,
TIterator end,
TOutputIterator out,
TUnaryPredicate predicate)
{
while (begin != end)
{
if (predicate(*begin))
{
*out = *begin;
++out;
}
++begin;
}
return out;
}
//***************************************************************************
/// all_of
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/all_any_none_of"></a>
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
bool all_of(TIterator begin,
TIterator end,
TUnaryPredicate predicate)
{
return etl::find_if_not(begin, end, predicate) == end;
}
//***************************************************************************
/// any_of
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/all_any_none_of"></a>
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
bool any_of(TIterator begin,
TIterator end,
TUnaryPredicate predicate)
{
return etl::find_if(begin, end, predicate) != end;
}
//***************************************************************************
/// none_of
///\ingroup algorithm
///<a href="http://en.cppreference.com/w/cpp/algorithm/all_any_none_of"></a>
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_NODISCARD
ETL_CONSTEXPR14
bool none_of(TIterator begin,
TIterator end,
TUnaryPredicate predicate)
{
return etl::find_if(begin, end, predicate) == end;
}
#if ETL_NOT_USING_STL
//***************************************************************************
/// Sorts the elements.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
void sort(TIterator first, TIterator last, TCompare compare)
{
etl::shell_sort(first, last, compare);
}
//***************************************************************************
/// Sorts the elements.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
void sort(TIterator first, TIterator last)
{
etl::shell_sort(first, last, etl::less<typename etl::iterator_traits<TIterator>::value_type>());
}
//***************************************************************************
/// Sorts the elements.
/// Stable.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
void stable_sort(TIterator first, TIterator last, TCompare compare)
{
etl::insertion_sort(first, last, compare);
}
//***************************************************************************
/// Sorts the elements.
/// Stable.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
void stable_sort(TIterator first, TIterator last)
{
etl::insertion_sort(first, last, etl::less<typename etl::iterator_traits<TIterator>::value_type>());
}
#else
//***************************************************************************
/// Sorts the elements.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
void sort(TIterator first, TIterator last, TCompare compare)
{
std::sort(first, last, compare);
}
//***************************************************************************
/// Sorts the elements.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
void sort(TIterator first, TIterator last)
{
std::sort(first, last);
}
//***************************************************************************
/// Sorts the elements.
/// Stable.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
void stable_sort(TIterator first, TIterator last, TCompare compare)
{
std::stable_sort(first, last, compare);
}
//***************************************************************************
/// Sorts the elements.
/// Stable.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
void stable_sort(TIterator first, TIterator last)
{
std::stable_sort(first, last);
}
#endif
//***************************************************************************
/// Accumulates values.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename T>
ETL_CONSTEXPR14
T accumulate(TIterator first, TIterator last, T sum)
{
while (first != last)
{
sum = etl::move(sum) + *first;
++first;
}
return sum;
}
//***************************************************************************
/// Accumulates values.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename T, typename TBinaryOperation>
ETL_CONSTEXPR14
T accumulate(TIterator first, TIterator last, T sum, TBinaryOperation operation)
{
while (first != last)
{
sum = operation(etl::move(sum), *first);
++first;
}
return sum;
}
//***************************************************************************
/// Clamp values.
///\ingroup algorithm
//***************************************************************************
template<typename T, typename TCompare>
ETL_CONSTEXPR
const T& clamp(const T& value, const T& low, const T& high, TCompare compare)
{
return compare(value, low) ? low : compare(high, value) ? high : value;
}
template <typename T>
ETL_CONSTEXPR
const T& clamp(const T& value, const T& low, const T& high )
{
return clamp(value, low, high, etl::less<T>());
}
//***************************************************************************
/// Remove
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename T>
ETL_CONSTEXPR14
TIterator remove(TIterator first, TIterator last, const T& value)
{
first = etl::find(first, last, value);
if (first != last)
{
TIterator itr = first;
while (itr != last)
{
if (!(*itr == value))
{
*first = etl::move(*itr);
++first;
}
++itr;
}
}
return first;
}
//***************************************************************************
/// Remove If
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TUnaryPredicate>
ETL_CONSTEXPR14
TIterator remove_if(TIterator first, TIterator last, TUnaryPredicate predicate)
{
first = etl::find_if(first, last, predicate);
if (first != last)
{
TIterator itr = first;
while (itr != last)
{
if (!predicate(*itr))
{
*first = etl::move(*itr);
++first;
}
++itr;
}
}
return first;
}
}
//*****************************************************************************
// ETL extensions to the STL algorithms.
//*****************************************************************************
namespace etl
{
//***************************************************************************
/// copy_s
/// A safer form of copy where the smallest of the two ranges is used.
/// There is currently no STL equivalent.
/// Specialisation for random access iterators.
///\param i_begin Beginning of the input range.
///\param i_end End of the input range.
///\param o_begin Beginning of the output range.
///\param o_end End of the output range.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TOutputIterator>
ETL_CONSTEXPR14
typename etl::enable_if<etl::is_random_iterator<TInputIterator>::value &&
etl::is_random_iterator<TOutputIterator>::value, TOutputIterator>::type
copy_s(TInputIterator i_begin,
TInputIterator i_end,
TOutputIterator o_begin,
TOutputIterator o_end)
{
size_t s_size = etl::distance(i_begin, i_end);
size_t d_size = etl::distance(o_begin, o_end);
size_t size = (s_size < d_size) ? s_size : d_size;
return etl::copy(i_begin, i_begin + size, o_begin);
}
//***************************************************************************
/// copy
/// A safer form of copy where the smallest of the two ranges is used.
/// There is currently no STL equivalent.
/// Specialisation for non random access iterators.
///\param i_begin Beginning of the input range.
///\param i_end End of the input range.
///\param o_begin Beginning of the output range.
///\param o_end End of the output range.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TOutputIterator>
ETL_CONSTEXPR14
typename etl::enable_if<!etl::is_random_iterator<TInputIterator>::value ||
!etl::is_random_iterator<TOutputIterator>::value, TOutputIterator>::type
copy_s(TInputIterator i_begin,
TInputIterator i_end,
TOutputIterator o_begin,
TOutputIterator o_end)
{
while ((i_begin != i_end) && (o_begin != o_end))
{
*o_begin = *i_begin;
++o_begin;
++i_begin;
}
return o_begin;
}
//***************************************************************************
/// copy_n
/// A safer form of copy_n where the smallest of the two ranges is used.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TSize,
typename TOutputIterator>
ETL_CONSTEXPR14
TOutputIterator copy_n_s(TInputIterator i_begin,
TSize n,
TOutputIterator o_begin,
TOutputIterator o_end)
{
while ((n-- > 0) && (o_begin != o_end))
{
*o_begin = *i_begin;
++o_begin;
++i_begin;
}
return o_begin;
}
//***************************************************************************
/// copy_n
/// A safer form of copy_n where the smallest of the two ranges is used.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TSize1,
typename TOutputIterator,
typename TSize2>
ETL_CONSTEXPR14
TOutputIterator copy_n_s(TInputIterator i_begin,
TSize1 n1,
TOutputIterator o_begin,
TSize2 n2)
{
while ((n1-- > 0) && (n2-- > 0))
{
*o_begin = *i_begin;
++o_begin;
++i_begin;
}
return o_begin;
}
//***************************************************************************
/// copy_if
/// A safer form of copy_if where it terminates when the first end iterator is reached.
/// There is currently no STL equivelent.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TOutputIterator,
typename TUnaryPredicate>
ETL_CONSTEXPR14
TOutputIterator copy_if_s(TInputIterator i_begin,
TInputIterator i_end,
TOutputIterator o_begin,
TOutputIterator o_end,
TUnaryPredicate predicate)
{
while ((i_begin != i_end) && (o_begin != o_end))
{
if (predicate(*i_begin))
{
*o_begin = *i_begin;
++o_begin;
}
++i_begin;
}
return o_begin;
}
//***************************************************************************
/// copy_n_if
/// Combination of copy_n and copy_if.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TUnaryPredicate>
ETL_CONSTEXPR14
TOutputIterator copy_n_if(TInputIterator i_begin,
TSize n,
TOutputIterator o_begin,
TUnaryPredicate predicate)
{
while (n-- > 0)
{
if (predicate(*i_begin))
{
*o_begin = *i_begin;
++o_begin;
}
++i_begin;
}
return o_begin;
}
#if ETL_USING_CPP11
//***************************************************************************
/// move_s
/// A safer form of move where the smallest of the two ranges is used.
/// There is currently no STL equivalent.
/// Specialisation for random access iterators.
///\param i_begin Beginning of the input range.
///\param i_end End of the input range.
///\param o_begin Beginning of the output range.
///\param o_end End of the output range.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator, typename TOutputIterator>
ETL_CONSTEXPR14
typename etl::enable_if<etl::is_random_iterator<TInputIterator>::value &&
etl::is_random_iterator<TOutputIterator>::value, TOutputIterator>::type
move_s(TInputIterator i_begin,
TInputIterator i_end,
TOutputIterator o_begin,
TOutputIterator o_end)
{
size_t s_size = etl::distance(i_begin, i_end);
size_t d_size = etl::distance(o_begin, o_end);
size_t size = (s_size < d_size) ? s_size : d_size;
return etl::move(i_begin, i_begin + size, o_begin);
}
//***************************************************************************
/// move_s
/// A safer form of move where the smallest of the two ranges is used.
/// There is currently no STL equivalent.
/// Specialisation for non random access iterators.
///\param i_begin Beginning of the input range.
///\param i_end End of the input range.
///\param o_begin Beginning of the output range.
///\param o_end End of the output range.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator, typename TOutputIterator>
ETL_CONSTEXPR14
typename etl::enable_if<!etl::is_random_iterator<TInputIterator>::value ||
!etl::is_random_iterator<TOutputIterator>::value, TOutputIterator>::type
move_s(TInputIterator i_begin,
TInputIterator i_end,
TOutputIterator o_begin,
TOutputIterator o_end)
{
while ((i_begin != i_end) && (o_begin != o_end))
{
*o_begin = etl::move(*i_begin);
++i_begin;
++o_begin;
}
return o_begin;
}
#else
//***************************************************************************
/// move_s
/// C++03
/// A safer form of move where the smallest of the two ranges is used.
/// There is currently no STL equivalent.
/// Specialisation for non random access iterators.
///\param i_begin Beginning of the input range.
///\param i_end End of the input range.
///\param o_begin Beginning of the output range.
///\param o_end End of the output range.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator, typename TOutputIterator>
TOutputIterator move_s(TInputIterator i_begin,
TInputIterator i_end,
TOutputIterator o_begin,
TOutputIterator o_end)
{
// Move not supported. Defer to copy.
return etl::copy_s(i_begin, i_end, o_begin, o_end);
}
#endif
//***************************************************************************
/// binary_find
///\ingroup algorithm
/// Does a binary search and returns an iterator to the value or end if not found.
//***************************************************************************
template <typename TIterator, typename TValue>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator binary_find(TIterator begin,
TIterator end,
const TValue& value)
{
TIterator it = etl::lower_bound(begin, end, value);
if ((it == end) || (*it != value))
{
it = end;
}
return it;
}
//***************************************************************************
/// binary_find
///\ingroup algorithm
/// Does a binary search and returns an iterator to the value or end if not found.
//***************************************************************************
template <typename TIterator,
typename TValue,
typename TBinaryPredicate,
typename TBinaryEquality>
ETL_NODISCARD
ETL_CONSTEXPR14
TIterator binary_find(TIterator begin,
TIterator end,
const TValue& value,
TBinaryPredicate predicate,
TBinaryEquality equality)
{
TIterator it = etl::lower_bound(begin, end, value, predicate);
if ((it == end) || !equality(*it, value))
{
it = end;
}
return it;
}
//***************************************************************************
/// Like std::for_each but applies a predicate before calling the function.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator,
typename TUnaryFunction,
typename TUnaryPredicate>
ETL_CONSTEXPR14
TUnaryFunction for_each_if(TIterator begin,
const TIterator end,
TUnaryFunction function,
TUnaryPredicate predicate)
{
while (begin != end)
{
if (predicate(*begin))
{
function(*begin);
}
++begin;
}
return function;
}
//***************************************************************************
/// Like std::for_each but for 'n' iterations.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator,
typename TSize,
typename TUnaryFunction>
ETL_CONSTEXPR14
TIterator for_each_n(TIterator begin,
TSize n,
TUnaryFunction function)
{
while (n-- > 0)
{
function(*begin);
++begin;
}
return begin;
}
//***************************************************************************
/// Like std::for_each but applies a predicate before calling the function, for 'n' iterations
///\ingroup algorithm
//***************************************************************************
template <typename TIterator,
typename TSize,
typename TUnaryFunction,
typename TUnaryPredicate>
ETL_CONSTEXPR14
TIterator for_each_n_if(TIterator begin,
TSize n,
TUnaryFunction function,
TUnaryPredicate predicate)
{
while (n-- > 0)
{
if (predicate(*begin))
{
function(*begin);
}
++begin;
}
return begin;
}
//***************************************************************************
/// A safer form of std::transform where the transform returns when the first
/// range end is reached.
/// There is currently no STL equivalent.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator, typename TOutputIterator, typename TUnaryFunction>
ETL_CONSTEXPR14
TOutputIterator transform_s(TInputIterator i_begin,
TInputIterator i_end,
TOutputIterator o_begin,
TOutputIterator o_end,
TUnaryFunction function)
{
while ((i_begin != i_end) && (o_begin != o_end))
{
*o_begin = function(*i_begin);
++i_begin;
++o_begin;
}
return o_begin;
}
//***************************************************************************
/// Transform 'n' items.
/// Random iterators.
/// There is currently no STL equivalent.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TUnaryFunction>
ETL_CONSTEXPR14
void transform_n(TInputIterator i_begin,
TSize n,
TOutputIterator o_begin,
TUnaryFunction function)
{
TInputIterator i_end(i_begin);
etl::advance(i_end, n);
etl::transform(i_begin, i_end, o_begin, function);
}
//***************************************************************************
/// Transform 'n' items from two ranges.
/// Random iterators.
/// There is currently no STL equivalent.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator1,
typename TInputIterator2,
typename TSize,
typename TOutputIterator,
typename TBinaryFunction>
ETL_CONSTEXPR14
void transform_n(TInputIterator1 i_begin1,
TInputIterator2 i_begin2,
TSize n,
TOutputIterator o_begin,
TBinaryFunction function)
{
TInputIterator1 i_end1(i_begin1);
etl::advance(i_end1, n);
etl::transform(i_begin1, i_end1, i_begin2, o_begin, function);
}
//***************************************************************************
/// Like std::transform but applies a predicate before calling the function.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TOutputIterator,
typename TUnaryFunction,
typename TUnaryPredicate>
ETL_CONSTEXPR14
TOutputIterator transform_if(TInputIterator i_begin,
const TInputIterator i_end,
TOutputIterator o_begin,
TUnaryFunction function,
TUnaryPredicate predicate)
{
while (i_begin != i_end)
{
if (predicate(*i_begin))
{
*o_begin = function(*i_begin);
++o_begin;
}
++i_begin;
}
return o_begin;
}
//***************************************************************************
/// Like etl::transform_if but inputs from two ranges.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator1,
typename TInputIterator2,
typename TOutputIterator,
typename TBinaryFunction,
typename TBinaryPredicate>
ETL_CONSTEXPR14
TOutputIterator transform_if(TInputIterator1 i_begin1,
const TInputIterator1 i_end1,
TInputIterator2 i_begin2,
TOutputIterator o_begin,
TBinaryFunction function,
TBinaryPredicate predicate)
{
while (i_begin1 != i_end1)
{
if (predicate(*i_begin1, *i_begin2))
{
*o_begin = function(*i_begin1, *i_begin2);
++o_begin;
}
++i_begin1;
++i_begin2;
}
return o_begin;
}
//***************************************************************************
/// Like std::transform_if, for 'n' items.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator,
typename TSize,
typename TOutputIterator,
typename TUnaryFunction,
typename TUnaryPredicate>
ETL_CONSTEXPR14
TOutputIterator transform_n_if(TInputIterator i_begin,
TSize n,
TOutputIterator o_begin,
TUnaryFunction function,
TUnaryPredicate predicate)
{
while (n-- > 0)
{
if (predicate(*i_begin))
{
*o_begin = function(*i_begin);
++o_begin;
}
++i_begin;
}
return o_begin;
}
//***************************************************************************
/// Like etl::transform_if but inputs from two ranges for 'n' items.
///\ingroup algorithm
//***************************************************************************
template <typename TInputIterator1,
typename TInputIterator2,
typename TSize,
typename TOutputIterator,
typename TBinaryFunction,
typename TBinaryPredicate>
ETL_CONSTEXPR14
TOutputIterator transform_n_if(TInputIterator1 i_begin1,
TInputIterator2 i_begin2,
TSize n,
TOutputIterator o_begin,
TBinaryFunction function,
TBinaryPredicate predicate)
{
while (n-- > 0)
{
if (predicate(*i_begin1, *i_begin2))
{
*o_begin++ = function(*i_begin1, *i_begin2);
}
++i_begin1;
++i_begin2;
}
return o_begin;
}
//***************************************************************************
/// Transforms the elements from the range (begin, end) to two different ranges
/// depending on the value returned by the predicate.<br>
///\ingroup algorithm
//***************************************************************************
template <typename TSource, typename TDestinationTrue, typename TDestinationFalse,
typename TUnaryFunctionTrue, typename TUnaryFunctionFalse,
typename TUnaryPredicate>
ETL_CONSTEXPR14
ETL_OR_STD::pair<TDestinationTrue, TDestinationFalse> partition_transform(TSource begin,
TSource end,
TDestinationTrue destination_true,
TDestinationFalse destination_false,
TUnaryFunctionTrue function_true,
TUnaryFunctionFalse function_false,
TUnaryPredicate predicate)
{
while (begin != end)
{
if (predicate(*begin))
{
*destination_true = function_true(*begin);
++destination_true;
}
else
{
*destination_false = function_false(*begin);
++destination_false;
}
++begin;
}
return ETL_OR_STD::pair<TDestinationTrue, TDestinationFalse>(destination_true, destination_false);
}
//***************************************************************************
/// Transforms the elements from the ranges (begin1, end1) & (begin2)
/// to two different ranges depending on the value returned by the predicate.
///\ingroup algorithm
//***************************************************************************
template <typename TSource1,
typename TSource2,
typename TDestinationTrue,
typename TDestinationFalse,
typename TBinaryFunctionTrue,
typename TBinaryFunctionFalse,
typename TBinaryPredicate>
ETL_CONSTEXPR14
ETL_OR_STD::pair<TDestinationTrue, TDestinationFalse> partition_transform(TSource1 begin1,
TSource1 end1,
TSource2 begin2,
TDestinationTrue destination_true,
TDestinationFalse destination_false,
TBinaryFunctionTrue function_true,
TBinaryFunctionFalse function_false,
TBinaryPredicate predicate)
{
while (begin1 != end1)
{
if (predicate(*begin1, *begin2))
{
*destination_true = function_true(*begin1, *begin2);
++destination_true;
}
else
{
*destination_false = function_false(*begin1, *begin2);
++destination_false;
}
++begin1;
++begin2;
}
return ETL_OR_STD::pair<TDestinationTrue, TDestinationFalse>(destination_true, destination_false);
}
//***************************************************************************
/// Sorts the elements using shell sort.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
#if ETL_USING_STD_NAMESPACE
ETL_CONSTEXPR20
#else
ETL_CONSTEXPR14
#endif
void shell_sort(TIterator first, TIterator last, TCompare compare)
{
if (first == last)
{
return;
}
typedef typename etl::iterator_traits<TIterator>::difference_type difference_t;
difference_t n = etl::distance(first, last);
for (difference_t i = n / 2; i > 0; i /= 2)
{
for (difference_t j = i; j < n; ++j)
{
for (difference_t k = j - i; k >= 0; k -= i)
{
TIterator itr1 = first;
TIterator itr2 = first;
etl::advance(itr1, k);
etl::advance(itr2, k + i);
if (compare(*itr2, *itr1))
{
etl::iter_swap(itr1, itr2);
}
}
}
}
}
//***************************************************************************
/// Sorts the elements using shell sort.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
#if ETL_USING_STD_NAMESPACE
ETL_CONSTEXPR20
#else
ETL_CONSTEXPR14
#endif
void shell_sort(TIterator first, TIterator last)
{
etl::shell_sort(first, last, etl::less<typename etl::iterator_traits<TIterator>::value_type>());
}
//***************************************************************************
/// Sorts the elements using insertion sort.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
ETL_CONSTEXPR14
void insertion_sort(TIterator first, TIterator last, TCompare compare)
{
for (TIterator itr = first; itr != last; ++itr)
{
etl::rotate(etl::upper_bound(first, itr, *itr, compare), itr, etl::next(itr));
}
}
//***************************************************************************
/// Sorts the elements using insertion sort.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
ETL_CONSTEXPR14
void insertion_sort(TIterator first, TIterator last)
{
etl::insertion_sort(first, last, etl::less<typename etl::iterator_traits<TIterator>::value_type>());
}
//***************************************************************************
namespace private_algorithm
{
template <typename TIterator>
ETL_CONSTEXPR14
typename etl::enable_if<etl::is_forward_iterator<TIterator>::value, TIterator>::type
get_before_last(TIterator first_, TIterator last_)
{
TIterator last = first_;
TIterator lastplus1 = first_;
++lastplus1;
while (lastplus1 != last_)
{
++last;
++lastplus1;
}
return last;
}
template <typename TIterator>
ETL_CONSTEXPR14
typename etl::enable_if<etl::is_bidirectional_iterator<TIterator>::value, TIterator>::type
get_before_last(TIterator /*first_*/, TIterator last_)
{
TIterator last = last_;
--last;
return last;
}
template <typename TIterator>
ETL_CONSTEXPR14
typename etl::enable_if<etl::is_random_access_iterator<TIterator>::value, TIterator>::type
get_before_last(TIterator /*first_*/, TIterator last_)
{
return last_ - 1;
}
}
//***************************************************************************
/// Sorts the elements using selection sort.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
ETL_CONSTEXPR20
void selection_sort(TIterator first, TIterator last, TCompare compare)
{
TIterator min;
const TIterator ilast = private_algorithm::get_before_last(first, last);
const TIterator jlast = last;
for (TIterator i = first; i != ilast; ++i)
{
min = i;
TIterator j = i;
++j;
for (; j != jlast; ++j)
{
if (compare(*j, *min))
{
min = j;
}
}
using ETL_OR_STD::swap; // Allow ADL
swap(*i, *min);
}
}
//***************************************************************************
/// Sorts the elements using selection sort.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
ETL_CONSTEXPR20
void selection_sort(TIterator first, TIterator last)
{
selection_sort(first, last, etl::less<typename etl::iterator_traits<TIterator>::value_type>());
}
//***************************************************************************
/// Sorts the elements using heap sort.
/// Uses user defined comparison.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator, typename TCompare>
ETL_CONSTEXPR14
void heap_sort(TIterator first, TIterator last, TCompare compare)
{
if (!etl::is_heap(first, last, compare))
{
etl::make_heap(first, last, compare);
}
etl::sort_heap(first, last, compare);
}
//***************************************************************************
/// Sorts the elements using heap sort.
///\ingroup algorithm
//***************************************************************************
template <typename TIterator>
ETL_CONSTEXPR14
void heap_sort(TIterator first, TIterator last)
{
if (!etl::is_heap(first, last))
{
etl::make_heap(first, last);
}
etl::sort_heap(first, last);
}
//***************************************************************************
/// Returns the maximum value.
//***************************************************************************
#if ETL_USING_CPP11
template <typename T>
ETL_NODISCARD
constexpr const T& multimax(const T& a, const T& b)
{
return a < b ? b : a;
}
template <typename T, typename... Tx>
ETL_NODISCARD
constexpr const T& multimax(const T& t, const Tx&... tx)
{
return multimax(t, multimax(tx...));
}
#endif
//***************************************************************************
/// Returns the maximum value.
/// User supplied compare function.
//***************************************************************************
#if ETL_USING_CPP11
template <typename TCompare, typename T>
ETL_NODISCARD
constexpr const T& multimax_compare(TCompare compare, const T& a, const T& b)
{
return compare(a, b) ? b : a;
}
template <typename TCompare, typename T, typename... Tx>
ETL_NODISCARD
constexpr const T& multimax_compare(TCompare compare, const T& t, const Tx&... tx)
{
return multimax_compare(compare, t, multimax_compare(compare, tx...));
}
#endif
//***************************************************************************
/// Returns the maximum value.
//***************************************************************************
#if ETL_USING_CPP11
template <typename T>
ETL_NODISCARD
constexpr const T& multimin(const T& a, const T& b)
{
return a < b ? a : b;
}
template <typename T, typename... Tx>
ETL_NODISCARD
constexpr const T& multimin(const T& t, const Tx&... tx)
{
return multimin(t, multimin(tx...));
}
#endif
//***************************************************************************
/// Returns the minimum value.
/// User supplied compare function.
//***************************************************************************
#if ETL_USING_CPP11
template <typename TCompare, typename T>
ETL_NODISCARD
constexpr const T& multimin_compare(TCompare compare, const T& a, const T& b)
{
return compare(a, b) ? a : b;
}
template <typename TCompare, typename T, typename... Tx>
ETL_NODISCARD
constexpr const T& multimin_compare(TCompare compare, const T& t, const Tx&... tx)
{
return multimin_compare(compare, t, multimin_compare(compare, tx...));
}
#endif
//***************************************************************************
/// Returns the iterator to the maximum value.
//***************************************************************************
#if ETL_USING_CPP11
template <typename TIterator>
ETL_NODISCARD
constexpr const TIterator& multimax_iter(const TIterator& a, const TIterator& b)
{
return *a < *b ? b : a;
}
template <typename TIterator, typename... TIteratorx>
ETL_NODISCARD
constexpr const TIterator& multimax_iter(const TIterator& t, const TIteratorx&... tx)
{
return multimax_iter(t, multimax_iter(tx...));
}
#endif
//***************************************************************************
/// Returns the iterator to the maximum value.
/// User supplied compare function.
//***************************************************************************
#if ETL_USING_CPP11
template <typename TCompare, typename TIterator>
ETL_NODISCARD
constexpr const TIterator& multimax_iter_compare(TCompare compare, const TIterator& a, const TIterator& b)
{
return compare(*a, *b) ? b : a;
}
template <typename TCompare, typename TIterator, typename... TIteratorx>
ETL_NODISCARD
constexpr const TIterator& multimax_iter_compare(TCompare compare, const TIterator& t, const TIteratorx&... tx)
{
return multimax_iter_compare(compare, t, multimax_iter_compare(compare, tx...));
}
#endif
//***************************************************************************
/// Returns the iterator to the minimum value.
//***************************************************************************
#if ETL_USING_CPP11
template <typename TIterator>
ETL_NODISCARD
constexpr const TIterator& multimin_iter(const TIterator& a, const TIterator& b)
{
return *a < *b ? a : b;
}
template <typename TIterator, typename... Tx>
ETL_NODISCARD
constexpr const TIterator& multimin_iter(const TIterator& t, const Tx&... tx)
{
return multimin_iter(t, multimin_iter(tx...));
}
#endif
//***************************************************************************
/// Returns the iterator to the minimum value.
/// User supplied compare function.
//***************************************************************************
#if ETL_USING_CPP11
template <typename TCompare, typename TIterator>
ETL_NODISCARD
constexpr const TIterator& multimin_iter_compare(TCompare compare, const TIterator& a, const TIterator& b)
{
return compare(*a, *b) ? a : b;
}
template <typename TCompare, typename TIterator, typename... Tx>
ETL_NODISCARD
constexpr const TIterator& multimin_iter_compare(TCompare compare, const TIterator& t, const Tx&... tx)
{
return multimin_iter_compare(compare, t, multimin_iter_compare(compare, tx...));
}
#endif
}
#include "private/minmax_pop.h"
#endif
|
{
"content_hash": "7bcb6da6cb7327cf71a06e9c9f40eb09",
"timestamp": "",
"source": "github",
"line_count": 2967,
"max_line_length": 143,
"avg_line_length": 29.875294910684193,
"alnum_prop": 0.48218637184115526,
"repo_name": "ETLCPP/etl",
"id": "cb287de187f9ff8c307dcd5e64c2621d0746ccb7",
"size": "90015",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "include/etl/algorithm.h",
"mode": "33188",
"license": "mit",
"language": [
{
"name": "Batchfile",
"bytes": "1390"
},
{
"name": "C",
"bytes": "142129"
},
{
"name": "C++",
"bytes": "12234060"
},
{
"name": "CMake",
"bytes": "65410"
},
{
"name": "Meson",
"bytes": "9008"
},
{
"name": "Python",
"bytes": "8272"
},
{
"name": "Shell",
"bytes": "35420"
}
]
}
|
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Char8 as C
import qualified Data.IntMap.Strict as IntMap
import Data.IntMap.Strict(IntMap)
import Data.Maybe
fromList :: [ (Int, Int) ] -> IntMap Int
fromList = foldl acc IntMap.empty
where acc m (!i, !j) = IntMap.insert i 1 . IntMap.insert j (-1) $ m
iter = fst . IntMap.foldlWithKey acc (0, 0)
where acc (!r, !c) k v = (r', c')
where c' = c + v
r' = max r c'
readint = fst . fromJust . C.readInt
readpair s = (x, y)
where (x:y:_) = map readint (C.words s)
process = iter . fromList
processinputs 0 _ = return ()
processinputs k (n:s) = print (process is) >> processinputs (pred k) s'
where (s1, s') = splitAt (readint n) s
is = map readpair s1
processall (nt:s) = processinputs (readint nt) s
main = C.getContents >>= processall . C.lines
|
{
"content_hash": "d6fb9431d58b2c85c83eff96d7536d6c",
"timestamp": "",
"source": "github",
"line_count": 29,
"max_line_length": 71,
"avg_line_length": 29.448275862068964,
"alnum_prop": 0.6358313817330211,
"repo_name": "wangbj/haskell",
"id": "1d48ed566c0cc9069f7c1635b84df2dead31dfbf",
"size": "854",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "bytese2.hs",
"mode": "33188",
"license": "bsd-2-clause",
"language": [
{
"name": "Haskell",
"bytes": "176687"
}
]
}
|
package io.aos.endpoint.socket.bio;
import java.net.*;
import java.io.*;
import java.util.*;
public class BioTcpWebRedirector implements Runnable {
private int port;
private String newSite;
public static void main(String... args) {
int thePort;
String theSite;
try {
theSite = args[0];
// trim trailing slash
if (theSite.endsWith("/")) {
theSite = theSite.substring(0, theSite.length()-1);
}
}
catch (Exception e) {
System.out.println(
"Usage: java Redirector http://www.newsite.com/ port");
return;
}
try {
thePort = Integer.parseInt(args[1]);
}
catch (Exception e) {
thePort = 80;
}
Thread t = new Thread(new BioTcpWebRedirector(theSite, thePort));
t.start();
}
public BioTcpWebRedirector(String site, int port) {
this.port = port;
this.newSite = site;
}
public void run() {
try {
ServerSocket server = new ServerSocket(this.port);
System.out.println("Redirecting connections on port "
+ server.getLocalPort() + " to " + newSite);
while (true) {
try {
Socket s = server.accept();
Thread t = new RedirectThread(s);
t.start();
} // end try
catch (IOException e) {
}
} // end while
} // end try
catch (BindException e) {
System.err.println("Could not start server. Port Occupied");
}
catch (IOException e) {
System.err.println(e);
}
} // end run
class RedirectThread extends Thread {
private Socket connection;
RedirectThread(Socket s) {
this.connection = s;
}
public void run() {
try {
Writer outputStream = new BufferedWriter(
new OutputStreamWriter(
connection.getOutputStream(), "ASCII"
)
);
Reader inputStream= new InputStreamReader(
new BufferedInputStream(
connection.getInputStream()
)
);
// read the first line only; that's all we need
StringBuffer request = new StringBuffer(80);
while (true) {
int c = inputStream.read();
if (c == '\r' || c == '\n' || c == -1) break;
request.append((char) c);
}
// If this is HTTP/1.0 or later send a MIME header
String get = request.toString();
int firstSpace = get.indexOf(' ');
int secondSpace = get.indexOf(' ', firstSpace+1);
String theFile = get.substring(firstSpace+1, secondSpace);
if (get.indexOf("HTTP/") != -1) {
outputStream.write("HTTP/1.0 302 FOUND\r\n");
Date now = new Date();
outputStream.write("Date: " + now + "\r\n");
outputStream.write("Server: Redirector 1.0\r\n");
outputStream.write("Location: " + newSite + theFile + "\r\n");
outputStream.write("Content-type: text/html\r\n\r\n");
outputStream.flush();
}
// Not all browsers support redirection so we need to
// produce HTML that says where the document has moved to.
outputStream.write("<HTML><HEAD><TITLE>Document moved</TITLE></HEAD>\r\n");
outputStream.write("<BODY><H1>Document moved</H1>\r\n");
outputStream.write("The document " + theFile
+ " has moved to\r\n<A HREF=\"" + newSite + theFile + "\">" + newSite
+ theFile + "</A>.\r\n Please update your bookmarks<P>");
outputStream.write("</BODY></HTML>\r\n");
outputStream.flush();
} // end try
catch (IOException e) {
}
finally {
try {
if (connection != null) connection.close();
}
catch (IOException e) {}
}
} // end run
}
}
|
{
"content_hash": "1fcfb765f962671a2db708d5cb3ef0e0",
"timestamp": "",
"source": "github",
"line_count": 147,
"max_line_length": 83,
"avg_line_length": 27.64625850340136,
"alnum_prop": 0.515994094488189,
"repo_name": "XClouded/t4f-core",
"id": "ababbc703878107ece882238ec2ff2eee58941a1",
"size": "5252",
"binary": false,
"copies": "1",
"ref": "refs/heads/master",
"path": "java/io/src/main/java/io/aos/endpoint/socket/bio/BioTcpWebRedirector.java",
"mode": "33188",
"license": "apache-2.0",
"language": []
}
|
namespace dbus {
// Utility class to ensure that DBusError is freed.
class ScopedDBusError {
public:
ScopedDBusError() {
dbus_error_init(&error_);
}
~ScopedDBusError() {
dbus_error_free(&error_);
}
DBusError* get() { return &error_; }
bool is_set() { return dbus_error_is_set(&error_); }
const char* name() { return error_.name; }
const char* message() { return error_.message; }
private:
DBusError error_;
};
} // namespace dbus
#endif // DBUS_SCOPED_DBUS_ERROR_H_
|
{
"content_hash": "ace98d9c426f8d65c21c3a086b89086c",
"timestamp": "",
"source": "github",
"line_count": 25,
"max_line_length": 54,
"avg_line_length": 20.08,
"alnum_prop": 0.6434262948207171,
"repo_name": "keishi/chromium",
"id": "67056477e5b3d6f7dcbdf7210dc0c5e3f257100b",
"size": "765",
"binary": false,
"copies": "3",
"ref": "refs/heads/master",
"path": "dbus/scoped_dbus_error.h",
"mode": "33188",
"license": "bsd-3-clause",
"language": [
{
"name": "ASP",
"bytes": "853"
},
{
"name": "Arduino",
"bytes": "464"
},
{
"name": "Assembly",
"bytes": "1172794"
},
{
"name": "C",
"bytes": "67452317"
},
{
"name": "C#",
"bytes": "1132"
},
{
"name": "C++",
"bytes": "132681259"
},
{
"name": "F#",
"bytes": "381"
},
{
"name": "Go",
"bytes": "19048"
},
{
"name": "Java",
"bytes": "361412"
},
{
"name": "JavaScript",
"bytes": "16603687"
},
{
"name": "Objective-C",
"bytes": "9609581"
},
{
"name": "PHP",
"bytes": "97796"
},
{
"name": "Perl",
"bytes": "918683"
},
{
"name": "Python",
"bytes": "6407891"
},
{
"name": "R",
"bytes": "524"
},
{
"name": "Shell",
"bytes": "4192593"
},
{
"name": "Tcl",
"bytes": "277077"
}
]
}
|
End of preview.
No dataset card yet
- Downloads last month
- 3