Skip to content

Commit 06e894b

Browse files
committed
added primitive documentation
1 parent d82954f commit 06e894b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Insertion Sort/InsertionSort.swift

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/// Performs the Insertion sort algorithm to a given array
2+
///
3+
/// - Parameters:
4+
/// - array: the array of elements to be sorted
5+
/// - isOrderedBefore: returns true if the elements provided are in the corect order
6+
/// - Returns: a sorted array containing the same elements
17
func insertionSort<T>(_ array: [T], _ isOrderedBefore: (T, T) -> Bool) -> [T] {
28
guard array.count > 1 else { return array }
39

@@ -14,6 +20,10 @@ func insertionSort<T>(_ array: [T], _ isOrderedBefore: (T, T) -> Bool) -> [T] {
1420
return a
1521
}
1622

23+
/// Performs the Insertion sort algorithm to a given array
24+
///
25+
/// - Parameter array: the array to be sorted, conatining elements that conform to the Comparable protocol
26+
/// - Returns: a sorted array containing the same elements
1727
func insertionSort<T: Comparable>(_ array: [T]) -> [T] {
1828
var a = array
1929
for x in 1..<a.count {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)