nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: TheAlgorithms/Java
Pull request #4299 (2023-08-12 10:22:02)

Add Reverse Bits Algo in Bit-Manipulation
<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.


BamaCharanChhandogi: Hi, @siriak Check!


Patch:
diff --git a/src/main/java/com/thealgorithms/bitmanipulation/ReverseBits.java b/src/main/java/com/thealgorithms/bitmanipulation/ReverseBits.java
new file mode 100644
index 00000000..58359598
--- /dev/null
+++ b/src/main/java/com/thealgorithms/bitmanipulation/ReverseBits.java
@@ -0,0 +1,20 @@
+package com.thealgorithms.bitmanipulation;
+
+/**
+ * Converts any Octal Number to a Binary Number
+ * @author Bama Charan Chhandogi
+ */
+
+public class ReverseBits {
+
+    public static int reverseBits(int n) {
+        int result = 0;
+        int bitCount = 32;
+        for (int i = 0; i < bitCount; i++) {
+            result <<= 1; // Left shift the result to make space for the next bit
+            result |= (n & 1); // OR operation to set the least significant bit of result with the current bit of n
+            n >>= 1; // Right shift n to move on to the next bit
+        }
+        return result;
+    }
+}
\ No newline at end of file


Test patch:
diff --git a/src/test/java/com/thealgorithms/bitmanipulation/ReverseBitsTest.java b/src/test/java/com/thealgorithms/bitmanipulation/ReverseBitsTest.java
new file mode 100644
index 00000000..730e3456
--- /dev/null
+++ b/src/test/java/com/thealgorithms/bitmanipulation/ReverseBitsTest.java
@@ -0,0 +1,15 @@
+package com.thealgorithms.bitmanipulation;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
+class ReverseBitsTest {
+
+    @Test
+    void testReverseBits() {
+        assertEquals(0, ReverseBits.reverseBits(0));
+        assertEquals(-1, ReverseBits.reverseBits(-1));
+        assertEquals(964176192, ReverseBits.reverseBits(43261596));
+    }
+}
Repository: TheAlgorithms/Java
Pull request #4301 (2023-08-12 17:43:08)

Is Even Algo added
<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.


BamaCharanChhandogi: Hi, @siriak Check!

Patch:
diff --git a/src/main/java/com/thealgorithms/bitmanipulation/IsEven.java b/src/main/java/com/thealgorithms/bitmanipulation/IsEven.java
new file mode 100644
index 00000000..c9129e47
--- /dev/null
+++ b/src/main/java/com/thealgorithms/bitmanipulation/IsEven.java
@@ -0,0 +1,12 @@
+package com.thealgorithms.bitmanipulation;
+
+/**
+ * Converts any Octal Number to a Binary Number
+ * @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
+ */
+
+public class IsEven {
+    public static boolean isEven(int number) {
+        return (number & 1) == 0;
+    }
+}
\ No newline at end of file


Test patch:
diff --git a/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java b/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java
new file mode 100644
index 00000000..2e33539f
--- /dev/null
+++ b/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java
@@ -0,0 +1,14 @@
+package com.thealgorithms.bitmanipulation;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
+class IsEvenTest {
+    @Test
+    void testIsEven() {
+        assertEquals(true, IsEven.isEven(2));
+        assertEquals(true, IsEven.isEven(-12));
+        assertEquals(false, IsEven.isEven(21));
+    }
+}
Repository: TheAlgorithms/Java
Pull request #4325 (2023-08-22 19:28:10)

Add Index Of Right Most Set Bit Test
<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.



Patch:
diff --git a/src/main/java/com/thealgorithms/bitmanipulation/IndexOfRightMostSetBit.java b/src/main/java/com/thealgorithms/bitmanipulation/IndexOfRightMostSetBit.java
new file mode 100644
index 00000000..4b1ca51e
--- /dev/null
+++ b/src/main/java/com/thealgorithms/bitmanipulation/IndexOfRightMostSetBit.java
@@ -0,0 +1,28 @@
+package com.thealgorithms.bitmanipulation;
+
+/**
+ * Find The Index Of Right Most SetBit
+ * @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
+ */
+
+public class IndexOfRightMostSetBit {
+    public static int indexOfRightMostSetBit(int n) {
+        if (n == 0) {
+            return -1; // No set bits
+        }
+
+        // Handle negative numbers by finding the two's complement
+        if (n < 0) {
+            n = -n;
+            n = n & (~n + 1); // Get the rightmost set bit in positive form
+        }
+
+        int index = 0;
+        while ((n & 1) == 0) {
+            n = n >> 1;
+            index++;
+        }
+
+        return index;
+    }
+}
\ No newline at end of file


Test patch:
diff --git a/src/test/java/com/thealgorithms/bitmanipulation/IndexOfRightMostSetBitTest.java b/src/test/java/com/thealgorithms/bitmanipulation/IndexOfRightMostSetBitTest.java
new file mode 100644
index 00000000..f377793c
--- /dev/null
+++ b/src/test/java/com/thealgorithms/bitmanipulation/IndexOfRightMostSetBitTest.java
@@ -0,0 +1,20 @@
+package com.thealgorithms.bitmanipulation;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Test case for Index Of Right Most SetBit
+ * @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
+ */
+
+class IndexOfRightMostSetBitTest {
+
+    @Test
+    void testIndexOfRightMostSetBit() {
+        assertEquals(3, IndexOfRightMostSetBit.indexOfRightMostSetBit(40));
+        assertEquals(-1, IndexOfRightMostSetBit.indexOfRightMostSetBit(0));
+        assertEquals(3, IndexOfRightMostSetBit.indexOfRightMostSetBit(-40));
+    }
+}
\ No newline at end of file
Repository: TheAlgorithms/Java
Pull request #4348 (2023-09-02 09:11:53)

Adding SetBit to bitmanipulation
<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [ ] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.


lukasb1b: Im sorry im new to github and I accedently resubmittet it. Can you explain to me how I need to change it?
siriak: You can find problems here https://github.com/TheAlgorithms/Java/actions/runs/6060803308/job/16453536079?pr=4348
These are indentation and spaces
![image](https://github.com/TheAlgorithms/Java/assets/29201949/ebe91d6d-15b5-480c-8325-29e525c7542f)

lukasb1b: I now changed the formatting i hope thats it
siriak: Not yet :) See output of the failing job

Patch:
diff --git a/src/main/java/com/thealgorithms/bitmanipulation/SetBit.java b/src/main/java/com/thealgorithms/bitmanipulation/SetBit.java
new file mode 100644
index 00000000..a4854001
--- /dev/null
+++ b/src/main/java/com/thealgorithms/bitmanipulation/SetBit.java
@@ -0,0 +1,10 @@
+package com.thealgorithms.bitmanipulation;
+/**
+ * Sets a specific bit to 1
+ */
+
+public class SetBit {
+    public static int setBit(int num, int bit) {
+        return num | (1 << bit);
+    }
+}


Test patch:
diff --git a/src/test/java/com/thealgorithms/bitmanipulation/SetBit.java b/src/test/java/com/thealgorithms/bitmanipulation/SetBit.java
new file mode 100644
index 00000000..b6d2514e
--- /dev/null
+++ b/src/test/java/com/thealgorithms/bitmanipulation/SetBit.java
@@ -0,0 +1,13 @@
+package com.thealgorithms.bitmanipulation;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
+class SetBitTest {
+    @Test
+    void testSetBit() {
+        assertEquals(5, SetBit.setBit(4, 0));
+        assertEquals(3, SetBit.setBit(3, 1));
+    }
+}
Repository: TheAlgorithms/Java
Pull request #4355 (2023-09-07 13:12:05)

Adding Clear bit
<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.



Patch:
diff --git a/src/main/java/com/thealgorithms/bitmanipulation/ClearBit.java b/src/main/java/com/thealgorithms/bitmanipulation/ClearBit.java
new file mode 100644
index 00000000..c863c46c
--- /dev/null
+++ b/src/main/java/com/thealgorithms/bitmanipulation/ClearBit.java
@@ -0,0 +1,11 @@
+package com.thealgorithms.bitmanipulation;
+/**
+ * Clears the bit located at clear from num
+ */
+
+public class ClearBit {
+    public static int clearBit(int num, int clear) {
+        int mask = ~(1 << clear);
+        return num & mask;
+    }
+}


Test patch:
diff --git a/src/test/java/com/thealgorithms/bitmanipulation/ClearBitTest.java b/src/test/java/com/thealgorithms/bitmanipulation/ClearBitTest.java
new file mode 100644
index 00000000..60f73e9d
--- /dev/null
+++ b/src/test/java/com/thealgorithms/bitmanipulation/ClearBitTest.java
@@ -0,0 +1,13 @@
+package com.thealgorithms.bitmanipulation;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
+public class ClearBitTest {
+    @Test
+    public void clearBitTest() {
+        assertEquals(5, ClearBit.clearBit(7, 1));
+        assertEquals(5, ClearBit.clearBit(5, 1));
+    }
+}
Repository: TheAlgorithms/Java
Pull request #4456 (2023-09-30 19:42:59)

Add `ReverseWordsInString`
<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.


Suchiq: > \n

added replace all to remove whitespace char from the string, please review
vil02: > > \n
> 
> added replace all to remove whitespace char from the string, please review

Could you also add a test case when such operation occurs?
Suchiq: > > > \n
> > 
> > 
> > added replace all to remove whitespace char from the string, please review
> 
> Could you also add a test case when such operation occurs?

done

Patch:
diff --git a/src/main/java/com/thealgorithms/strings/ReverseWordsInString.java b/src/main/java/com/thealgorithms/strings/ReverseWordsInString.java
new file mode 100644
index 00000000..5f9d27b4
--- /dev/null
+++ b/src/main/java/com/thealgorithms/strings/ReverseWordsInString.java
@@ -0,0 +1,22 @@
+package com.thealgorithms.strings;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+public final class ReverseWordsInString {
+
+    private ReverseWordsInString() {
+    }
+
+    /**
+     * @brief Reverses words in the input string
+     * @param s the input string
+     * @return A string created by reversing the order of the words in {@code s}
+     */
+
+    public static String reverseWordsInString(final String s) {
+        var words = s.trim().split("\\s+");
+        Collections.reverse(Arrays.asList(words));
+        return String.join(" ", words);
+    }
+}


Test patch:
diff --git a/src/test/java/com/thealgorithms/strings/ReverseWordsInStringTest.java b/src/test/java/com/thealgorithms/strings/ReverseWordsInStringTest.java
new file mode 100644
index 00000000..44e39745
--- /dev/null
+++ b/src/test/java/com/thealgorithms/strings/ReverseWordsInStringTest.java
@@ -0,0 +1,20 @@
+package com.thealgorithms.strings;
+
+import java.util.stream.Stream;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+public class ReverseWordsInStringTest {
+    @ParameterizedTest
+    @MethodSource("inputStream")
+    void numberTests(String expected, String input) {
+        Assertions.assertEquals(expected, ReverseWordsInString.reverseWordsInString(input));
+    }
+
+    private static Stream<Arguments> inputStream() {
+        return Stream.of(Arguments.of("blue is Sky", "Sky is blue"), Arguments.of("blue is Sky", "Sky \n is \t \n  blue "), Arguments.of("", ""), Arguments.of("", "    "), Arguments.of("", "\t"));
+    }
+}
Repository: TheAlgorithms/Java
Pull request #4707 (2023-10-07 07:48:58)

Issue #4706 Solved
Import Package into the RecursiveBinarySearchTest and RecursiveBinarySearch

<!--
Thank you for your contribution!
In order to reduce the number of notifications sent to the maintainers, please:
- create your PR as draft, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests,
- make sure that all of the CI checks pass,
- mark your PR as ready for review, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review
-->

<!-- For completed items, change [ ] to [x] -->

- [ ] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [ ] This pull request is all my own work -- I have not plagiarized it.
- [ ] All filenames are in PascalCase.
- [ ] All functions and variable names follow Java naming conventions.
- [ ] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.



Patch:
diff --git a/src/main/java/com/thealgorithms/searches/RecursiveBinarySearch.java b/src/main/java/com/thealgorithms/searches/RecursiveBinarySearch.java
index 8a02b30a..0a84aa1d 100644
--- a/src/main/java/com/thealgorithms/searches/RecursiveBinarySearch.java
+++ b/src/main/java/com/thealgorithms/searches/RecursiveBinarySearch.java
@@ -2,7 +2,7 @@
 // Created:- 1/10/2023
 // File Name should be RecursiveBinarySearch.java
 // Explanation:- https://www.tutorialspoint.com/java-program-for-binary-search-recursive
-
+package com.thealgorithms.searches;
 import java.util.*;
 
 // Create a SearchAlgorithm class with a generic type


Test patch:
diff --git a/src/test/java/com/thealgorithms/searches/RecursiveBinarySearchTest.java b/src/test/java/com/thealgorithms/searches/RecursiveBinarySearchTest.java
index 3b2cdead..4144efa5 100644
--- a/src/test/java/com/thealgorithms/searches/RecursiveBinarySearchTest.java
+++ b/src/test/java/com/thealgorithms/searches/RecursiveBinarySearchTest.java
@@ -1,6 +1,7 @@
 // Created by Pronay Debnath
 // Date:- 1/10/2023
 // Test file updated with JUnit tests
+package com.thealgorithms.searches;
 
 import static org.junit.jupiter.api.Assertions.*;
Repository: TheAlgorithms/Java
Pull request #4990 (2024-01-02 17:53:50)

Add Set Kth Bit
<!--
Thank you for your contribution!
In order to reduce the number of notifications sent to the maintainers, please:
- create your PR as draft, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests,
- make sure that all of the CI checks pass,
- mark your PR as ready for review, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review
-->

<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/CONTRIBUTING.md).
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
- [x] All new code is formatted with `clang-format -i --style=file path/to/your/file.java`


Patch:
diff --git a/src/main/java/com/thealgorithms/bitmanipulation/SetKthBit.java b/src/main/java/com/thealgorithms/bitmanipulation/SetKthBit.java
new file mode 100644
index 00000000..3c4e50d1
--- /dev/null
+++ b/src/main/java/com/thealgorithms/bitmanipulation/SetKthBit.java
@@ -0,0 +1,22 @@
+package com.thealgorithms.bitmanipulation;
+
+/***
+ * Sets the kth bit of a given integer to 1
+ * e.g. setting 3rd bit in binary of 17 (binary 10001) gives 25 (binary 11001)
+ * @author inishantjain
+ */
+
+public class SetKthBit {
+    /**
+     * Sets the kth bit of a given integer.
+     *
+     * @param num The original integer.
+     * @param k   The position of the bit to set (0-based index).
+     * @return The integer with the kth bit set.
+     */
+    public static int setKthBit(int num, int k) {
+        int mask = 1 << k;
+        num = num | mask;
+        return num;
+    }
+}


Test patch:
diff --git a/src/test/java/com/thealgorithms/bitmanipulation/SetKthBitTest.java b/src/test/java/com/thealgorithms/bitmanipulation/SetKthBitTest.java
new file mode 100644
index 00000000..35d5fa35
--- /dev/null
+++ b/src/test/java/com/thealgorithms/bitmanipulation/SetKthBitTest.java
@@ -0,0 +1,23 @@
+package com.thealgorithms.bitmanipulation;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
+class SetKthBitTest {
+
+    @Test
+    void testSetKthBit() {
+        // Test case: Setting the 0th bit in 5 (binary 101)
+        assertEquals(5, SetKthBit.setKthBit(5, 0));
+
+        // Test case: Setting the 2nd bit in 10 (binary 1010)
+        assertEquals(14, SetKthBit.setKthBit(10, 2));
+
+        // Test case: Setting the 3rd bit in 15 (binary 1111)
+        assertEquals(15, SetKthBit.setKthBit(15, 3));
+
+        // Test case: Setting the 1st bit in 0 (binary 0)
+        assertEquals(2, SetKthBit.setKthBit(0, 1));
+    }
+}
Repository: jensneuse/graphql-go-tools
Pull request #273 (2021-08-11 08:44:46)

handle comment inside parseFieldDefinitionList
Hi, Thanks to develop great project!

I tried to use federation gateway to my toy project.
but it isn't works well... 😿 
I investigated codes & found issue.

My code include commented out field in object type definitions.
likes below.

```
"""
テスト用のデータです。
"""
type FooBar @goModel(model: "github.com/vvakame/test/foobar.FooBar") {
    name: String
    # logoURL: String
}
```



Patch:
diff --git a/pkg/astparser/parser.go b/pkg/astparser/parser.go
index f16f3fec..b7b54182 100644
--- a/pkg/astparser/parser.go
+++ b/pkg/astparser/parser.go
@@ -959,6 +959,8 @@ func (p *Parser) parseFieldDefinitionList() (list ast.FieldDefinitionList) {
 				refsInitialized = true
 			}
 			list.Refs = append(list.Refs, ref)
+		case keyword.COMMENT:
+			p.read()
 		default:
 			p.errUnexpectedToken(p.read())
 			return


Test patch:
diff --git a/pkg/astparser/parser_test.go b/pkg/astparser/parser_test.go
index 30576e13..5fdd2e5e 100644
--- a/pkg/astparser/parser_test.go
+++ b/pkg/astparser/parser_test.go
@@ -786,6 +786,50 @@ func TestParser_Parse(t *testing.T) {
 				}
 			})
 		})
+		t.Run("with comment-out field", func(t *testing.T) {
+			run(`type Person {
+							   name: String
+							   # tbd: String
+							   age: Int
+							}`, parse, false, func(doc *ast.Document, extra interface{}) {
+				person := doc.ObjectTypeDefinitions[0]
+				personName := doc.Input.ByteSliceString(person.Name)
+				if personName != "Person" {
+					t.Fatal("want person")
+				}
+
+				// field definitions
+				if len(person.FieldsDefinition.Refs) != 2 {
+					t.Fatal("want 2")
+				}
+				nameString := doc.FieldDefinitions[person.FieldsDefinition.Refs[0]]
+				name := doc.Input.ByteSliceString(nameString.Name)
+				if name != "name" {
+					t.Fatal("want name")
+				}
+				nameStringType := doc.Types[nameString.Type]
+				if nameStringType.TypeKind != ast.TypeKindNamed {
+					t.Fatal("want TypeKindNamed")
+				}
+				stringName := doc.Input.ByteSliceString(nameStringType.Name)
+				if stringName != "String" {
+					t.Fatal("want String")
+				}
+				ageInt := doc.FieldDefinitions[person.FieldsDefinition.Refs[1]]
+				age := doc.Input.ByteSliceString(ageInt.Name)
+				if age != "age" {
+					t.Fatal("want age")
+				}
+				ageIntType := doc.Types[ageInt.Type]
+				if ageIntType.TypeKind != ast.TypeKindNamed {
+					t.Fatal("want TypeKindNamed")
+				}
+				intAge := doc.Input.ByteSliceString(ageIntType.Name)
+				if intAge != "Int" {
+					t.Fatal("want String")
+				}
+			})
+		})
 		t.Run("implements & without next", func(t *testing.T) {
 			run(`type Person implements Foo & {}`, parse, true)
 		})