id
stringlengths
36
36
text
stringlengths
1
1.25M
c9e3ed64-0b5a-4a4b-9a8b-7a44dd400023
public String getName();
1508c04c-5d87-450f-8e04-56d2cbbe34b0
public boolean movePlayerOnBoard(GameBoard gameBoard);
01a43241-bb63-42eb-b1da-f68b0e1fbe90
public String getName();
d82a7fa7-e7c0-4629-9629-56c85c2ed73c
public UpdateSplitterPlugin() { this(new DelimiterSplitter(";")); }
6e74019a-0bb5-4c0c-a700-c367163ff8e1
public UpdateSplitterPlugin(TextSplitter splitter) { this.splitter = splitter; }
c81dbe24-99de-4a34-8627-7e08741ad768
public UpdateSplitterPlugin(TextSplitter splitter, boolean skipEmptyStatements) { this.splitter = splitter; this.skipEmptyStatements = skipEmptyStatements; }
8b4fa287-648f-499e-963c-44ef408f21ee
@Override public Object intercept(Invocation invocation) throws Throwable { MappedStatement ms = (MappedStatement) invocation.getArgs()[0]; Object parameterObject = invocation.getArgs()[1]; final Configuration configuration = ms.getConfiguration(); final StatementHandler handler = co...
a364da26-4b1f-4698-afff-17ec5981b4ad
@Override public Object plugin(Object target) { if (reusePreparedStatements && target instanceof BatchExecutor) { target = replaceBatchExecutor((BatchExecutor) target); } if (reusePreparedStatements && target instanceof CachingExecutor) { try { Object ...
1fe1f43c-f61e-4f5d-aa65-35483fae4e29
private Object replaceBatchExecutor(BatchExecutor target) { try { return new ReusingBatchExecutor((Configuration) executorConfiguration.get(target), target.getTransaction(), retainExecuteOrder, reuseBetweenFlushes); } catch (IllegalAccessException e) { throw n...
e15f7970-f8ae-436c-9a8d-74ed7900d553
@Override public void setProperties(Properties properties) { String property = properties.getProperty(SPLIT_EXPRESSION_PROPERTY); if (property != null) { splitter = new RegexpSplitter(property); } property = properties.getProperty(DELIMITER_PROPERTY); if (property...
0a80d9cb-9799-4b34-9b3b-53b56f3ace68
private boolean getBooleanProperty(Properties properties, String name, boolean def) { String property; property = properties.getProperty(name); return property != null ? Boolean.parseBoolean(property) : def; }
e3ca5551-4df1-4b44-9ea9-4b4a47ee3183
public ReusingBatchExecutor(Configuration configuration, Transaction transaction, boolean retainExecuteOrder, boolean reuseBetweenFlushes) { super(configuration, transaction); this.retainExecuteOrder = retainExecuteOrder; this.reuseBetweenFlushes = reuseBetweenFlushes; }
91ef0e5b-017a-4fb7-9aaa-3ccbdb98a981
public int doUpdate(MappedStatement ms, Object parameterObject) throws SQLException { final Configuration configuration = ms.getConfiguration(); final StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, RowBounds.DEFAULT, null, null); final BoundSql boundSql =...
be1f7261-a5c4-47e9-817a-7f029e6bd4e2
public <E> List<E> doQuery(MappedStatement ms, Object parameterObject, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException { Statement stmt = null; try { flushStatements(); Configuration configuration = ms.getConfiguration(); ...
03234d63-98a1-463f-b152-d88fc4a32151
public List<BatchResult> doFlushStatements(boolean isRollback) throws SQLException { try { if (isRollback) { return Collections.emptyList(); } else { return executeStatements(); } } finally { for (StatementData stmt : statem...
da2730cd-ee8a-44cf-9459-8041b3d69bbf
private List<BatchResult> executeStatements() throws SQLException { executeUpTo(null, false); List<BatchResult> batchResults = results; results = new ArrayList<BatchResult>(); return batchResults; }
4f04f3b8-5369-4eed-a492-313981534e2e
private void executeUpTo(PreparedStatementKey lastToExecute, boolean moveToReuse) throws SQLException { for (Iterator<Map.Entry<PreparedStatementKey, StatementData>> iterator = statementsData.entrySet().iterator(); iterator.hasNext(); ) { Map.Entry<PreparedStatementKey, StatementData> entry = iterat...
42912d44-4f46-4dd8-819a-e39179220212
protected PreparedStatementKey(String sql, MappedStatement mappedStatement) { this.sql = sql; this.mappedStatement = mappedStatement; hashCode = sql.hashCode() * 31 + mappedStatement.hashCode(); }
c48f74c2-6612-4621-a9f4-ecb14ce35905
public String getSql() { return sql; }
8046e4b6-cc8f-4726-a932-4645bd9307b1
public MappedStatement getMappedStatement() { return mappedStatement; }
23d9441f-42b8-4a50-961b-053c02bf5ebf
@Override public int hashCode() { return hashCode; }
05385383-411d-4554-b04c-7db42380c233
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PreparedStatementKey that = (PreparedStatementKey) o; if (!sql.equals(that.sql)) return false; if (!mappedStatement.equ...
eedab0ce-32b6-42ad-a65c-9c83f9b8ccb7
public StatementData(Statement statement) { this.statement = statement; }
7c7c6851-3a32-4c1e-8fc4-f012fa1fc35f
public Statement getStatement() { return statement; }
ca6ed378-8902-47c0-81b8-257ae558d97a
public void addParameterObject(Object parameterObject) { parameterObjects.add(parameterObject); }
f4cad42e-fcda-440f-8fd6-3ce808f6743b
public List<Object> getParameterObjects() { return parameterObjects; }
57ad4b50-c667-44a6-9e7c-1acd85e31a08
public RegexpSplitter(String splitPattern) { this(Pattern.compile(splitPattern, Pattern.MULTILINE)); }
28ec4e5a-4226-4ee5-b1ad-04365c4349ec
public RegexpSplitter(Pattern splitPattern) { this.splitPattern = splitPattern; }
1bdfe492-8afc-4176-b3b0-b7a79a1127ec
@Override public List<String> split(String text) { return Arrays.asList(splitPattern.split(text)); }
590bced9-ab22-4ba5-a5da-7e7ecc01efc0
List<String> split(String text);
afac3485-97a7-4096-9afc-ebee14051eef
SwitchingSqlSource(Configuration configuration) { this.configuration = configuration; }
16354fed-1e28-4f32-82ac-f5d4cd2149c6
public SwitchingSqlSource(Configuration configuration, String sql, BoundSql boundSql, List<ParameterMapping> parameterMappings) { this.sql = sql; this.parameterMappings = parameterMappings; this.configuration = configuration; this.parentBoundSql = boundSql; }
89b5ef3d-0945-4810-acdb-e2e443c91871
@Override public BoundSql getBoundSql(Object parameterObject) { BoundSql subBoundSql = new BoundSql(configuration, sql, parameterMappings, parameterObject); for (ParameterMapping parameterMapping: subBoundSql.getParameterMappings()) { String property = new PropertyTokenizer(parameterMapp...
8f5279bd-dfb9-46b5-87ca-e40a64eb9bed
public void switchParams(String sql, BoundSql parentBoundSql, List<ParameterMapping> parameterMappings) { this.sql = sql; this.parentBoundSql = parentBoundSql; this.parameterMappings = parameterMappings; }
368fdd21-1e1a-422f-a0b4-a128d32188d8
public void setSql(String sql) { this.sql = sql; }
3b2a9917-eb53-4f23-8b90-57ae58c975b5
public void setParameterMappings(List<ParameterMapping> parameterMappings) { this.parameterMappings = parameterMappings; }
f2a5066b-42a5-4c9c-9947-8d87f51a59ca
public void setParentBoundSql(BoundSql parentBoundSql) { this.parentBoundSql = parentBoundSql; }
f99699b2-d018-4196-8d83-810c8c008b5a
public DelimiterSplitter(String delimiter) { this.delimiter = delimiter; }
d24ed7bf-512a-400e-8468-60ab66bda599
@Override public List<String> split(String text) { List<String> splitted = new ArrayList<String>(); StringTokenizer tokenizer = new StringTokenizer(text, delimiter); while(tokenizer.hasMoreTokens()) { splitted.add(tokenizer.nextToken().trim()); } return splitted; ...
4ce181c2-a442-404e-bb12-680537b50124
@Test public void splitterTestSimple() throws IOException, SQLException { splitterTest(ExecutorType.SIMPLE); }
f456b908-a62a-47ee-b3cb-025a43b46abe
@Test public void splitterTestBatch() throws IOException, SQLException { splitterTest(ExecutorType.BATCH); }
d06ce524-aa21-47f3-83af-87e1829bf694
public void splitterTest(ExecutorType execType) throws IOException, SQLException { SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build( Resources.getResourceAsStream("configuration.xml")); SqlSession sqlSession = sqlSessionFactory.openSession(execType); sql...
c700520f-224f-4571-865c-c03cd0460b07
private void doInsert(SqlSession sqlSession) { Map<String, Object> param = new HashMap<String, Object>(); param.put("first", "first"); param.put("other", Arrays.asList("second", "third")); sqlSession.insert("multy", param); sqlSession.flushStatements(); }
0619dfe8-d156-47ac-af81-a2ef6b13cdb7
@Test public void mockTest() throws IOException, SQLException { expect(connection.getAutoCommit()).andStubReturn(false); expect(connection.prepareStatement("insert into test values(?)")).andReturn(statement); statement.setString(1, "first"); statement.addBatch(); statement.se...
e4896aa0-af5f-4eb1-89c1-c6b93bb160d8
public Prime(){ super(); }
34bf8fd6-a980-47d0-83a4-a9a21f43fc48
public boolean isPrime1(int n ) { for(int i = 2;i<n;i++) { int rem = n % i; if(n % i == 0) return false; } return true; }
75dee789-f9ce-4d78-a614-fc301d3e4e29
public boolean isPrime2(int n) { if(n==1) return true; if(n==2) return true; if(n%2==0) return false; int m = (int)Math.sqrt((int)n); for(int i=3;i<=m;i+=2) if(n%i==0) return false; return true; }
b14f5f74-2d06-404c-922b-73198e7f8b17
public static void main(String args[]) { Prime p = new Prime(); long start = System.currentTimeMillis(); int counter = 0; for(int i = 1;i<100000;i++) { if(p.isPrime1(i)) counter++; } long end = System.currentTimeMillis(); /...
fbe874b5-a925-4d39-9aa6-7dfb1dabf0f4
public static void main(String[] args){ int[] x = {2,3,1,8,4,6}; int [] y = {1,2,3,4,5,6}; new QuickSort().sort(x); System.out.println(Arrays.toString(x)); }
4e55120e-0f53-49a3-bd60-cc876e9b38aa
public void sort(int[] arr){ quicksort(arr, 0, arr.length-1); }
dc4d550c-7719-4a9a-a357-f2f71aebdfd4
private void quicksort(int[] arr,int low, int high){ int lo = low,hi=high; int pivotValue = arr[low+(high-low)/2]; while(lo<=hi){ while(arr[lo] < pivotValue) lo++; while(arr[hi] > pivotValue) hi--; if(lo<=hi){ swap(arr,lo,hi); lo++;hi--; } } if(low<hi) quicksort(arr, low, hi...
6270f94b-1f25-4607-8c17-975c6d83dba0
private void swap(int arr[],int i,int j){ int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; }
de22e8a5-f383-48f9-b682-cce512d978cc
public BaseConversion2() { mapping.put('0', 0); mapping.put('1', 1); mapping.put('2', 2); mapping.put('3', 3); mapping.put('4', 4); mapping.put('5', 5); mapping.put('6', 6); mapping.put('7', 7); mapping.put('8', 8); mapping.put('9', 9); ...
570574a9-da14-4bec-ac3b-61aa7e08e2f4
public String betweenBases(String input,int b1,int b2) { return toBase(toDecimal(input, b1), b2); }
f9f6653b-b6ad-448b-839d-41fd2ead0d96
private int toDecimal(String input,int b1) { int multiplier = 1; int result = 0; for(int i = input.length()-1;i>=0;i--) { result += mapping.get(input.charAt(i))*multiplier; multiplier *= b1; } return result; }
4a0c929c-4b7a-4766-b1f2-8001422da372
private String toBase(int decValue, int b2) { StringBuilder sb = new StringBuilder(); while(decValue>0) { sb.append(arr[decValue%b2]); decValue /= b2; } sb.reverse(); return sb.toString(); }
2ba99c47-1258-47d3-9f9e-e3123f7a84c9
public static void main(String args[]) { BaseConversion2 baseConversion = new BaseConversion2(); System.out.println(baseConversion.betweenBases("1000011011000100", 2, 16)); }
e09cbff8-5236-4700-bf5c-a6c6006584d0
public Node(int value){ this.value = value; left = right = null; }
f51a5aec-1632-44b4-bada-1e0d31905c87
public static void inorder(Node root){ if(root == null) return; inorder(root.left); System.out.println(root.value + " "); inorder(root.right); }
601b97cb-36ad-44eb-80d8-3c79e79f03d1
public static void addNode(Node root, Node newNode){ if(newNode.value < root.value){ if(root.left != null) addNode(root.left, newNode); else root.left = newNode; } else{ if(root.right != null) addNode(root.right,...
c85f8e11-3eec-4cf7-920a-deb9a0811671
public static void kBiggest(Node root, int K){ Offset offset = new Offset(); offset.offest = 0; kBiggest(root, K, offset); }
cebcd96a-0f44-49ab-b2b0-bc13c4e1918d
private static void kBiggest(Node root, int K, Offset current){ if(root == null) return; kBiggest(root.right, K, current); if(K == current.offest){ System.out.println(root.value); current.offest++; return; } else{ curre...
e9675866-d1a5-4ee8-ba94-fa08fe438323
public static void main(String[] args){ Node root = new Node(5); addNode(root, new Node(3)); addNode(root, new Node(7)); addNode(root, new Node(2)); addNode(root, new Node(9)); addNode(root, new Node(1)); addNode(root, new Node(4)); inorder(root); ...
e35171d1-945e-4465-a56c-0351580cb310
public static List<String> perm(String in){ return perm(in,"",in.length()); }
5670654b-5485-4eb1-8d72-adc9023d01ed
public static List<String> perm(String in, String out, int length){ List<String> list = new LinkedList<String>(); if(out.length() ==length){ list.add(out); } else{ for(int i = 0; i< in.length();i++){ String rest; if(i==0) ...
8ec09d0d-1aed-4356-a9f6-0de0e130900a
public static void main(String [] args){ System.out.println(perm("abc")); }
6d0b9ba2-7e05-4f9f-9400-e7b95739af01
public static void main(String args[]) { //uncomment to run sample cases runSamples(); }
41cad4ef-64fb-4bfe-a662-2d5b0a2cc263
public static void runSamples() { //The following outputs the P unique random elements from the input string //The first tries to get P unique from a null array int[] a =null; System.out.println(Arrays.toString(returnRandomNonDuplicates(a, 4))); //The second tries to get P u...
d9ad0cbf-e5e4-438c-ac46-7e0230434d35
private static int[] uniqueElements(int[] input) { //this method creates a unique set of elements from the input array Set<Integer> set = new HashSet<Integer>(); for(int i = 0 ; i< input.length;i++) { set.add(input[i]); } int[] output = new int[set.size()]...
ae7c12d0-2b0a-4996-8791-d983e80f32c8
private static int[] createRandomArray(int[] input, int N) { //There is a more efficient way of doing this and that is by replacing the i'th entry with the last //entry of the array and decrementing by one //for example //lets say our input array is {1,2,3,4,5} //our random n...
e9ee8845-21aa-4ed7-97e5-00a7ff00d146
public static int[] returnRandomNonDuplicates(int[] input,int P) { if(input == null) return null; int[] uniqueElems = uniqueElements(input); //should this function not be able to return P unique elements, //I have decided to make the function return the unique elements ...
0599a30b-a117-46af-9d29-07bfb16edfb7
public BaseConversion() { mapping.put('0', 0); mapping.put('1', 1); mapping.put('2', 2); mapping.put('3', 3); mapping.put('4', 4); mapping.put('5', 5); mapping.put('6', 6); mapping.put('7', 7); mapping.put('8', 8); mapping.put('9', 9); ...
8c1d434d-6e53-4efd-a79f-2d746ef4ca81
public String betweenBases(String input,int b1,int b2){ int dec = ToDecimal(input, b1); return toBase(dec, b2); }
b579cedd-39dd-4b2f-800e-b14f1a4751a6
public String toBase(int decVal,int b){ StringBuilder sb = new StringBuilder(); while(decVal>0){ sb.append(arr[decVal%b]); decVal = decVal/b; } sb.reverse(); return sb.toString(); }
69dcf106-515c-4e61-b7b0-8f73f73a22d3
public int ToDecimal(String val, int b){ int multiplier = 1; int result = 0; for(int i = val.length()-1;i>=0;i--){ result += mapping.get(val.charAt(i)) * multiplier; multiplier *=b; } return result; }
78c8a7a7-5b56-4263-ad08-b80d4f828022
public int ToDecimal(int n,int b){ int multiplier = 1; int result = 0; while(n>0) { result += (n%10)*multiplier; n/=10; multiplier *=b; } return result; }
18e387a4-a414-494e-8fbc-29a78b22b5c6
public static void main(String args[]){ BaseConversion baseConversion = new BaseConversion(); System.out.println(baseConversion.betweenBases("8", 10, 2)); }
9130d383-0773-43a8-bd16-bdfbfd6c97ca
public void ShortestPath() { for(int k = 0;k<6;k++) { for(int i = 0; i<6;i++) { for(int j = 0;j<6;j++) { int x = arr[i][j]; int y = arr[i][k]; int z = arr[k][j]; in...
ade3ee48-d6d2-4ec6-af31-189804ac353c
public void Print() { for(int i = 0; i<6;i++) { for(int j = 0;j<6;j++) { if(arr[i][j] == max) { System.out.print(" 0 "); } else { ...
abecf6f3-5fca-4569-a5a9-351d473726bf
public static void main(String args[]) { FloydWarshall floydWarshall = new FloydWarshall(); System.out.println("Input graph"); floydWarshall.Print(); System.out.println("\nAfter FloydWarshall alg"); floydWarshall.ShortestPath(); floydWarshall.Print(); }
6ee59cf3-e9e5-4c61-a27f-efcc9aa27451
public static int knapsack(int W, int[] wt,int[] val,int n){ int dp[][] = new int[W+1][n+1]; for(int i =0;i<=W;i++){ dp[i][n] = 0; } for(int i =0;i<=n;i++){ dp[0][i] = 0; } for(int i = n-1;i>=0;i--){ for(int j = 0;j<=W;j++){ ...
fae84819-d867-4d68-98eb-693fac09012f
public static void main(String [] args){ int [] val = {60,100,120}; int [] wt = {10,20,30}; int W = 50; System.out.println(knapsack(W, wt, val, 3)); }
3e300891-d455-416c-8f35-32383b12ec9b
public static List<String> choose(String in, int c){ return choose(in,"",c); }
109fef9b-ad26-423d-b034-f2e080a1c896
public static List<String> choose(String in, String out, int c){ List<String> list = new LinkedList<String>(); if(out.length() == c){ list.add(out); } else{ for(int i = 0;i< in.length();i++){ list.addAll(choose(in.substring(i+1),out+in.charAt(i),c)...
aad8740e-dec1-46d1-9d5b-394b64b151a6
public static void main(String [] args){ System.out.println(choose("abcd",4)); }
dae5f5e8-8bd7-4e77-8b3d-a362f84ed1ea
private void init(){ arr.clear(); for(int i = 0 ; i < 10;i++){ List<Integer> temp = new LinkedList<Integer>(); arr.add(i,temp); } }
da741e3e-f2a5-4a2a-83a4-d0d590c3c17e
public RadixSort(){ init(); }
8b581fa0-e202-443c-bc5d-4922aa65c932
private void add(int number,int multiple){ int x = number%multiple; int y = x/(multiple/10); arr.get(y).add(number); }
5031004d-4739-4903-8324-700beef3b70c
private int[] toArray(){ int[] temp = new int[sizeOfInput]; int counter = 0; for(int i = 0;i < arr.size();i++){ List<Integer> tempList = arr.get(i); for(int j = 0;j<tempList.size();j++){ temp[counter++] = tempList.get(j); } } re...
6b3be349-ba6e-4ace-a3f4-50e5e31284a2
public int[] sort(int[] input){ int n = 10; sizeOfInput = input.length; for(int k = 0;k<10;k++){ for(int i = 0;i< input.length;i++){ add(input[i], n); } input = toArray(); init(); n *= 10; } return input;...
c4d00a20-6a27-4c49-993a-9b4f1fcadb2e
public static void main(String args[]){ int in[] = {9,8,350,7,3000,5,4,200,3,1,2,100}; RadixSort radixSort = new RadixSort(); int out[] = radixSort.sort(in); System.out.println(Arrays.toString(out)); }
c27922c8-5885-4b93-b2bf-6d342bbb180b
public boolean isPrime(int n) { if(n==1) return true; if(n==2) return false; if(n%2==0) return false; int m = (int)Math.sqrt((int)n); for(int i = 3;i<=m;i++) { if(n%i==0) return false; } return true; ...
58bd5e5a-b0c4-47a2-8b05-590b11ffcff6
public static void main(String[] args) { Main p = new Main(); long start = System.currentTimeMillis(); int counter = 0; for(int i = 1;i<100000;i++) { if(p.isPrime(i)) counter++; } long end = System.currentTimeMillis(); System.o...
484f0f44-8bb1-4ed1-b380-4c301be0af73
public static boolean binarySearch(int[] input, int element,int lower, int upper) { // int midPoint = (upper-lower)/2 + offset; int midPoint = (upper-lower)/2 + lower; int midval = input[midPoint]; if(input[midPoint] == element) return true; if(upper==lower) ...
5940c2c5-0705-4599-a11b-ebcb9e5c7fb1
public static void main(String[] args) { int [] x = {2,4,6,8,10,12,14,16,18,20}; System.out.println(binarySearch(x,21, 0, x.length)); }
8ad4e74c-38e9-42a3-89a5-f4720b7860e9
public boolean isPrime1(int n ) { for(int i = 2;i<n;i++) { int rem = n % i; if(n % i == 0) return false; } return true; }
d0eedc6c-c28b-4e6c-afa1-47582e6af764
public boolean isPrime2(int n) { if(n==1) return true; if(n==2) return true; if(n%2==0) return false; int m = (int)Math.sqrt((int)n); for(int i=3;i<=m;i+=2) if(n%i==0) return false; return true; }
0ebc5198-6e88-4b53-9ceb-0d8078ff102f
public static void main(String args[]) { Prime p = new Prime(); long start = System.currentTimeMillis(); int counter = 0; for(int i = 1;i<100000;i++) { if(p.isPrime1(i)) counter++; } long end = System.currentTimeMillis(); S...
ea221da1-8b48-42b2-8137-bb7406fe7448
public int Kadane(int[] arr){ int max=0,soFar=0; for(int i = 0;i<arr.length;i++){ soFar = Math.max(0, soFar+arr[i]); max = Math.max(soFar,max); } return max; }
4fbab502-30f0-45f2-bbbf-9a14b328f71c
public static void mains(String[] args){ int[] arr ={-2, 1, -3, 4, -1, 2, 1, -5, 4}; System.out.println(new MaxSubArray().Kadane(arr)); }