| … | … | @@ -1655,6 +1655,354 @@ int intintIdentityPerfectCLHash_BufferInsertNoOverwrite(intintHash_Table * |
| 1655 | 1655 | return (0); |
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | typedef struct intintIdentityPerfectOpenMPHash_TableData { |
| 1659 | int hashID; |
| 1660 | unsigned int numBuckets; |
| 1661 | char compressFuncData; |
| 1662 | } intintIdentityPerfectOpenMPHash_TableData; |
| 1663 | typedef struct intintIdentityPerfectOpenMPHash_Bucket { |
| 1664 | int key; |
| 1665 | int value; |
| 1666 | } intintIdentityPerfectOpenMPHash_Bucket; |
| 1667 | intintHash_Table *intintIdentityPerfectOpenMPHash_CreateTable(intintHash_Factory |
| 1668 | * factory, |
| 1669 | int hashIndex, |
| 1670 | size_t keyRange, |
| 1671 | size_t numEntries, |
| 1672 | float loadFactor) |
| 1673 | { |
| 1674 | intintHash_Table *table = |
| 1675 | (intintHash_Table *) malloc(sizeof(intintHash_Table)); |
| 1676 | table->destroyFunc = &intintIdentityPerfectOpenMPHash_DestroyTable; |
| 1677 | table->emptyFunc = &intintIdentityPerfectOpenMPHash_EmptyTable; |
| 1678 | table->queryFunc = &intintIdentityPerfectOpenMPHash_Query; |
| 1679 | table->querySingleFunc = &intintIdentityPerfectOpenMPHash_QuerySingle; |
| 1680 | table->insertFunc = &intintIdentityPerfectOpenMPHash_Insert; |
| 1681 | table->insertSingleFunc = &intintIdentityPerfectOpenMPHash_InsertSingle; |
| 1682 | table->insertNoOverwriteFunc = |
| 1683 | &intintIdentityPerfectOpenMPHash_InsertNoOverwrite; |
| 1684 | table->insertSingleNoOverwriteFunc = |
| 1685 | &intintIdentityPerfectOpenMPHash_InsertSingleNoOverwrite; |
| 1686 | table->tableData = |
| 1687 | (char *)malloc(sizeof(intintIdentityPerfectOpenMPHash_TableData)); |
| 1688 | ((intintIdentityPerfectOpenMPHash_TableData *) table->tableData)-> |
| 1689 | hashID = IDENTITY_PERFECT_OPENMP_HASH_ID; |
| 1690 | ((intintIdentityPerfectOpenMPHash_TableData *) table->tableData)-> |
| 1691 | numBuckets = keyRange + 1; |
| 1692 | char *tempHashData = |
| 1693 | (char *)malloc(sizeof(intintIdentityPerfectOpenMPHash_TableData) + |
| 1694 | ((intintIdentityPerfectOpenMPHash_TableData *) |
| 1695 | table->tableData)->numBuckets * |
| 1696 | sizeof(intintIdentityPerfectOpenMPHash_Bucket)); |
| 1697 | memcpy(tempHashData, table->tableData, |
| 1698 | sizeof(intintIdentityPerfectOpenMPHash_TableData)); |
| 1699 | free(table->tableData); |
| 1700 | table->tableData = tempHashData; |
| 1701 | return table; |
| 1702 | } |
| 1703 | int intintIdentityPerfectOpenMPHash_CreateFactory(intintHash_Factory * factory, |
| 1704 | int hashIndex) { |
| 1705 | factory->createFunc[hashIndex] = |
| 1706 | &intintIdentityPerfectOpenMPHash_CreateTable; |
| 1707 | factory->destroyFunc[hashIndex] = |
| 1708 | &intintIdentityPerfectOpenMPHash_DestroyFactory;; |
| 1709 | return HASH_EXIT_CODE_NORMAL; |
| 1710 | } |
| 1711 | int intintIdentityPerfectOpenMPHash_DestroyFactory(intintHash_Factory * factory, |
| 1712 | int hashIndex) {; |
| 1713 | return HASH_EXIT_CODE_NORMAL; |
| 1714 | } |
| 1715 | int intintIdentityPerfectOpenMPHash_DestroyTable(intintHash_Table * table) { |
| 1716 | int exitCode = 0; |
| 1717 | free(table->tableData); |
| 1718 | free(table); |
| 1719 | return exitCode; |
| 1720 | } |
| 1721 | int intintIdentityPerfectOpenMPHash_EmptyTable(intintHash_Table * table) { |
| 1722 | int exitCode = 0; |
| 1723 | intintIdentityPerfectOpenMPHash_Bucket *buckets = |
| 1724 | (intintIdentityPerfectOpenMPHash_Bucket *) & table-> |
| 1725 | tableData[sizeof(intintIdentityPerfectOpenMPHash_TableData)]; |
| 1726 | int index; |
| 1727 | for (index = 0; |
| 1728 | index < |
| 1729 | ((intintIdentityPerfectOpenMPHash_TableData *) table->tableData)-> |
| 1730 | numBuckets; index++) { |
| 1731 | buckets[index].key = HASH_BUCKET_STATUS_EMPTY; |
| 1732 | } |
| 1733 | exitCode = HASH_EXIT_CODE_NORMAL; |
| 1734 | return exitCode; |
| 1735 | } |
| 1736 | int intintIdentityPerfectOpenMPHash_InnerQuerySingle(char *tableData, int key, |
| 1737 | int *valueOutput) { |
| 1738 | intintIdentityPerfectOpenMPHash_Bucket *buckets = |
| 1739 | (intintIdentityPerfectOpenMPHash_Bucket *) & |
| 1740 | tableData[sizeof(intintIdentityPerfectOpenMPHash_TableData)]; |
| 1741 | int index; |
| 1742 | int exitCode; |
| 1743 | index = |
| 1744 | intintHash_CompressIdentity(((intintIdentityPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 1745 | if ((buckets[index].key) != HASH_BUCKET_STATUS_EMPTY) { |
| 1746 | if (key == buckets[index].key) { |
| 1747 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 1748 | } else { |
| 1749 | exitCode = HASH_SEARCH_CODE_MISMATCH; |
| 1750 | } |
| 1751 | } else { |
| 1752 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 1753 | } |
| 1754 | switch (exitCode) { |
| 1755 | case HASH_SEARCH_CODE_MATCH: |
| 1756 | *valueOutput = buckets[index].value; |
| 1757 | return HASH_EXIT_CODE_NORMAL; |
| 1758 | case HASH_SEARCH_CODE_MISMATCH: |
| 1759 | case HASH_SEARCH_CODE_EMPTY: |
| 1760 | return HASH_EXIT_CODE_KEY_DNE; |
| 1761 | default: |
| 1762 | return exitCode; |
| 1763 | } |
| 1764 | } |
| 1765 | int intintIdentityPerfectOpenMPHash_InnerQuery(char *tableData, |
| 1766 | unsigned int numKeys, int *keys, |
| 1767 | int *valuesOutput) { |
| 1768 | intintIdentityPerfectOpenMPHash_Bucket *buckets = |
| 1769 | (intintIdentityPerfectOpenMPHash_Bucket *) & |
| 1770 | tableData[sizeof(intintIdentityPerfectOpenMPHash_TableData)]; |
| 1771 | int key; |
| 1772 | int *valueOutput; |
| 1773 | int index; |
| 1774 | int exitCode; |
| 1775 | uint i; |
| 1776 | int resultExitCode = HASH_EXIT_CODE_NORMAL; |
| 1777 | for (i = 0; i < numKeys; i++) { |
| 1778 | key = keys[i]; |
| 1779 | valueOutput = &valuesOutput[i]; |
| 1780 | index = |
| 1781 | intintHash_CompressIdentity(((intintIdentityPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 1782 | if ((buckets[index].key) != HASH_BUCKET_STATUS_EMPTY) { |
| 1783 | if (key == buckets[index].key) { |
| 1784 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 1785 | } else { |
| 1786 | exitCode = HASH_SEARCH_CODE_MISMATCH; |
| 1787 | } |
| 1788 | } else { |
| 1789 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 1790 | } |
| 1791 | switch (exitCode) { |
| 1792 | case HASH_SEARCH_CODE_MATCH: |
| 1793 | *valueOutput = buckets[index].value; |
| 1794 | break; |
| 1795 | case HASH_SEARCH_CODE_MISMATCH: |
| 1796 | case HASH_SEARCH_CODE_EMPTY: |
| 1797 | resultExitCode = HASH_EXIT_CODE_KEY_DNE; |
| 1798 | break; |
| 1799 | default: |
| 1800 | return exitCode; |
| 1801 | } |
| 1802 | } |
| 1803 | return resultExitCode; |
| 1804 | } |
| 1805 | int intintIdentityPerfectOpenMPHash_InnerInsertSingle(char *tableData, int key, |
| 1806 | int value) { |
| 1807 | intintIdentityPerfectOpenMPHash_Bucket *buckets = |
| 1808 | (intintIdentityPerfectOpenMPHash_Bucket *) & |
| 1809 | tableData[sizeof(intintIdentityPerfectOpenMPHash_TableData)]; |
| 1810 | int index; |
| 1811 | int exitCode; |
| 1812 | index = |
| 1813 | intintHash_CompressIdentity(((intintIdentityPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 1814 | if (((buckets[index].key == |
| 1815 | HASH_BUCKET_STATUS_EMPTY) ? (buckets[index].key = |
| 1816 | key, |
| 1817 | HASH_BUCKET_STATUS_EMPTY) : |
| 1818 | buckets[index].key) != HASH_BUCKET_STATUS_EMPTY) { |
| 1819 | if (key == buckets[index].key) { |
| 1820 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 1821 | } else { |
| 1822 | exitCode = HASH_SEARCH_CODE_MISMATCH; |
| 1823 | } |
| 1824 | } else { |
| 1825 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 1826 | } |
| 1827 | switch (exitCode) { |
| 1828 | case HASH_SEARCH_CODE_MATCH: |
| 1829 | case HASH_SEARCH_CODE_MISMATCH: |
| 1830 | buckets[index].value = value; |
| 1831 | return HASH_EXIT_CODE_OVERWRITE; |
| 1832 | case HASH_SEARCH_CODE_EMPTY: |
| 1833 | buckets[index].value = value; |
| 1834 | return HASH_EXIT_CODE_NORMAL; |
| 1835 | default: |
| 1836 | return exitCode; |
| 1837 | } |
| 1838 | } |
| 1839 | int intintIdentityPerfectOpenMPHash_InnerInsert(char *tableData, |
| 1840 | unsigned int numEntries, |
| 1841 | int *keys, int *values) { |
| 1842 | intintIdentityPerfectOpenMPHash_Bucket *buckets = |
| 1843 | (intintIdentityPerfectOpenMPHash_Bucket *) & |
| 1844 | tableData[sizeof(intintIdentityPerfectOpenMPHash_TableData)]; |
| 1845 | int resultExitCode = HASH_EXIT_CODE_NORMAL; |
| 1846 | int key; |
| 1847 | int value; |
| 1848 | int index; |
| 1849 | int exitCode; |
| 1850 | uint i; |
| 1851 | for (i = 0; i < numEntries; i++) { |
| 1852 | key = keys[i]; |
| 1853 | index = |
| 1854 | intintHash_CompressIdentity(((intintIdentityPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 1855 | if (((buckets[index].key == |
| 1856 | HASH_BUCKET_STATUS_EMPTY) ? (buckets[index].key = |
| 1857 | key, |
| 1858 | HASH_BUCKET_STATUS_EMPTY) : |
| 1859 | buckets[index].key) != HASH_BUCKET_STATUS_EMPTY) { |
| 1860 | if (key == buckets[index].key) { |
| 1861 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 1862 | } else { |
| 1863 | exitCode = HASH_SEARCH_CODE_MISMATCH; |
| 1864 | } |
| 1865 | } else { |
| 1866 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 1867 | } |
| 1868 | switch (exitCode) { |
| 1869 | case HASH_SEARCH_CODE_MATCH: |
| 1870 | case HASH_SEARCH_CODE_MISMATCH: |
| 1871 | resultExitCode = HASH_EXIT_CODE_OVERWRITE; |
| 1872 | case HASH_SEARCH_CODE_EMPTY: |
| 1873 | buckets[index].value = values[i]; |
| 1874 | break; |
| 1875 | default: |
| 1876 | return exitCode; |
| 1877 | } |
| 1878 | } |
| 1879 | return resultExitCode; |
| 1880 | } |
| 1881 | int intintIdentityPerfectOpenMPHash_InnerInsertSingleNoOverwrite(char |
| 1882 | *tableData, |
| 1883 | int key, |
| 1884 | int value) { |
| 1885 | intintIdentityPerfectOpenMPHash_Bucket *buckets = |
| 1886 | (intintIdentityPerfectOpenMPHash_Bucket *) & |
| 1887 | tableData[sizeof(intintIdentityPerfectOpenMPHash_TableData)]; |
| 1888 | int index; |
| 1889 | int exitCode; |
| 1890 | index = |
| 1891 | intintHash_CompressIdentity(((intintIdentityPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 1892 | if (((buckets[index].key == |
| 1893 | HASH_BUCKET_STATUS_EMPTY) ? (buckets[index].key = |
| 1894 | key, |
| 1895 | HASH_BUCKET_STATUS_EMPTY) : |
| 1896 | buckets[index].key) != HASH_BUCKET_STATUS_EMPTY) { |
| 1897 | if (key == buckets[index].key) { |
| 1898 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 1899 | } else { |
| 1900 | exitCode = HASH_SEARCH_CODE_MISMATCH; |
| 1901 | } |
| 1902 | } else { |
| 1903 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 1904 | } |
| 1905 | switch (exitCode) { |
| 1906 | case HASH_SEARCH_CODE_MATCH: |
| 1907 | case HASH_SEARCH_CODE_MISMATCH: |
| 1908 | return HASH_EXIT_CODE_OVERWRITE; |
| 1909 | case HASH_SEARCH_CODE_EMPTY: |
| 1910 | buckets[index].value = value; |
| 1911 | return HASH_EXIT_CODE_NORMAL; |
| 1912 | default: |
| 1913 | return exitCode; |
| 1914 | } |
| 1915 | } |
| 1916 | int intintIdentityPerfectOpenMPHash_InnerInsertNoOverwrite(char *tableData, |
| 1917 | unsigned int |
| 1918 | numEntries, |
| 1919 | int *keys, |
| 1920 | int *values) { |
| 1921 | intintIdentityPerfectOpenMPHash_Bucket *buckets = |
| 1922 | (intintIdentityPerfectOpenMPHash_Bucket *) & |
| 1923 | tableData[sizeof(intintIdentityPerfectOpenMPHash_TableData)]; |
| 1924 | int resultExitCode = HASH_EXIT_CODE_NORMAL; |
| 1925 | int key; |
| 1926 | int value; |
| 1927 | int index; |
| 1928 | int exitCode; |
| 1929 | uint i; |
| 1930 | for (i = 0; i < numEntries; i++) { |
| 1931 | key = keys[i]; |
| 1932 | index = |
| 1933 | intintHash_CompressIdentity(((intintIdentityPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 1934 | if (((buckets[index].key == |
| 1935 | HASH_BUCKET_STATUS_EMPTY) ? (buckets[index].key = |
| 1936 | key, |
| 1937 | HASH_BUCKET_STATUS_EMPTY) : |
| 1938 | buckets[index].key) != HASH_BUCKET_STATUS_EMPTY) { |
| 1939 | if (key == buckets[index].key) { |
| 1940 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 1941 | } else { |
| 1942 | exitCode = HASH_SEARCH_CODE_MISMATCH; |
| 1943 | } |
| 1944 | } else { |
| 1945 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 1946 | } |
| 1947 | switch (exitCode) { |
| 1948 | case HASH_SEARCH_CODE_MATCH: |
| 1949 | case HASH_SEARCH_CODE_MISMATCH: |
| 1950 | resultExitCode = HASH_EXIT_CODE_OVERWRITE; |
| 1951 | break; |
| 1952 | case HASH_SEARCH_CODE_EMPTY: |
| 1953 | buckets[index].value = values[i]; |
| 1954 | break; |
| 1955 | default: |
| 1956 | return exitCode; |
| 1957 | } |
| 1958 | } |
| 1959 | return resultExitCode; |
| 1960 | } |
| 1961 | int intintIdentityPerfectOpenMPHash_QuerySingle(intintHash_Table * table, |
| 1962 | int key, int *valueOutput) { |
| 1963 | return intintIdentityPerfectOpenMPHash_InnerQuerySingle(table-> |
| 1964 | tableData, key, |
| 1965 | valueOutput); |
| 1966 | } |
| 1967 | int intintIdentityPerfectOpenMPHash_Query(intintHash_Table * table, |
| 1968 | size_t numKeys, int *keys, |
| 1969 | int *valuesOutput) { |
| 1970 | return intintIdentityPerfectOpenMPHash_InnerQuery(table->tableData, |
| 1971 | numKeys, keys, |
| 1972 | valuesOutput); |
| 1973 | } |
| 1974 | int intintIdentityPerfectOpenMPHash_InsertSingle(intintHash_Table * table, |
| 1975 | int key, int value) { |
| 1976 | return intintIdentityPerfectOpenMPHash_InnerInsertSingle(table-> |
| 1977 | tableData, key, |
| 1978 | value); |
| 1979 | } |
| 1980 | int intintIdentityPerfectOpenMPHash_Insert(intintHash_Table * table, |
| 1981 | size_t numEntries, int *keys, |
| 1982 | int *values) { |
| 1983 | return intintIdentityPerfectOpenMPHash_InnerInsert(table->tableData, |
| 1984 | numEntries, keys, |
| 1985 | values); |
| 1986 | } |
| 1987 | int intintIdentityPerfectOpenMPHash_InsertSingleNoOverwrite(intintHash_Table * |
| 1988 | table, int key, |
| 1989 | int value) { |
| 1990 | return |
| 1991 | intintIdentityPerfectOpenMPHash_InnerInsertSingleNoOverwrite(table-> |
| 1992 | tableData, |
| 1993 | key, |
| 1994 | value); |
| 1995 | } |
| 1996 | int intintIdentityPerfectOpenMPHash_InsertNoOverwrite(intintHash_Table * table, |
| 1997 | size_t numEntries, |
| 1998 | int *keys, int *values) { |
| 1999 | return intintIdentityPerfectOpenMPHash_InnerInsertNoOverwrite(table-> |
| 2000 | tableData, |
| 2001 | numEntries, |
| 2002 | keys, |
| 2003 | values); |
| 2004 | } |
| 2005 | |
| 1658 | 2006 | typedef struct intintIdentitySentinelPerfectHash_TableData { |
| 1659 | 2007 | int hashID; |
| 1660 | 2008 | unsigned int numBuckets; |
| … | … | @@ -2402,6 +2750,360 @@ int intintIdentitySentinelPerfectCLHash_BufferInsertNoOverwrite(intintHash_Table |
| 2402 | 2750 | return (0); |
| 2403 | 2751 | } |
| 2404 | 2752 | |
| 2753 | typedef struct intintIdentitySentinelPerfectOpenMPHash_TableData { |
| 2754 | int hashID; |
| 2755 | unsigned int numBuckets; |
| 2756 | char compressFuncData; |
| 2757 | int emptyValue; |
| 2758 | } intintIdentitySentinelPerfectOpenMPHash_TableData; |
| 2759 | typedef struct intintIdentitySentinelPerfectOpenMPHash_Bucket { |
| 2760 | int value; |
| 2761 | } intintIdentitySentinelPerfectOpenMPHash_Bucket; |
| 2762 | intintHash_Table |
| 2763 | *intintIdentitySentinelPerfectOpenMPHash_CreateTable(intintHash_Factory * |
| 2764 | factory, int hashIndex, |
| 2765 | size_t keyRange, |
| 2766 | size_t numEntries, |
| 2767 | float loadFactor) { |
| 2768 | intintHash_Table *table = |
| 2769 | (intintHash_Table *) malloc(sizeof(intintHash_Table)); |
| 2770 | table->destroyFunc = |
| 2771 | &intintIdentitySentinelPerfectOpenMPHash_DestroyTable; |
| 2772 | table->emptyFunc = &intintIdentitySentinelPerfectOpenMPHash_EmptyTable; |
| 2773 | table->queryFunc = &intintIdentitySentinelPerfectOpenMPHash_Query; |
| 2774 | table->querySingleFunc = |
| 2775 | &intintIdentitySentinelPerfectOpenMPHash_QuerySingle; |
| 2776 | table->insertFunc = &intintIdentitySentinelPerfectOpenMPHash_Insert; |
| 2777 | table->insertSingleFunc = |
| 2778 | &intintIdentitySentinelPerfectOpenMPHash_InsertSingle; |
| 2779 | table->insertNoOverwriteFunc = |
| 2780 | &intintIdentitySentinelPerfectOpenMPHash_InsertNoOverwrite; |
| 2781 | table->insertSingleNoOverwriteFunc = |
| 2782 | &intintIdentitySentinelPerfectOpenMPHash_InsertSingleNoOverwrite; |
| 2783 | table->tableData = |
| 2784 | (char *) |
| 2785 | malloc(sizeof(intintIdentitySentinelPerfectOpenMPHash_TableData)); |
| 2786 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) table-> |
| 2787 | tableData)->hashID = IDENTITY_SENTINEL_PERFECT_OPENMP_HASH_ID; |
| 2788 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) table-> |
| 2789 | tableData)->emptyValue = factory->emptyValue; |
| 2790 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) table-> |
| 2791 | tableData)->numBuckets = keyRange + 1; |
| 2792 | char *tempHashData = |
| 2793 | (char *) |
| 2794 | malloc(sizeof(intintIdentitySentinelPerfectOpenMPHash_TableData) + |
| 2795 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) |
| 2796 | table->tableData)->numBuckets * |
| 2797 | sizeof(intintIdentitySentinelPerfectOpenMPHash_Bucket)); |
| 2798 | memcpy(tempHashData, table->tableData, |
| 2799 | sizeof(intintIdentitySentinelPerfectOpenMPHash_TableData)); |
| 2800 | free(table->tableData); |
| 2801 | table->tableData = tempHashData; |
| 2802 | return table; |
| 2803 | } |
| 2804 | int intintIdentitySentinelPerfectOpenMPHash_CreateFactory(intintHash_Factory * |
| 2805 | factory, |
| 2806 | int hashIndex) { |
| 2807 | factory->createFunc[hashIndex] = |
| 2808 | &intintIdentitySentinelPerfectOpenMPHash_CreateTable; |
| 2809 | factory->destroyFunc[hashIndex] = |
| 2810 | &intintIdentitySentinelPerfectOpenMPHash_DestroyFactory;; |
| 2811 | return HASH_EXIT_CODE_NORMAL; |
| 2812 | } |
| 2813 | int intintIdentitySentinelPerfectOpenMPHash_DestroyFactory(intintHash_Factory * |
| 2814 | factory, |
| 2815 | int hashIndex) {; |
| 2816 | return HASH_EXIT_CODE_NORMAL; |
| 2817 | } |
| 2818 | int intintIdentitySentinelPerfectOpenMPHash_DestroyTable(intintHash_Table * |
| 2819 | table) { |
| 2820 | int exitCode = 0; |
| 2821 | free(table->tableData); |
| 2822 | free(table); |
| 2823 | return exitCode; |
| 2824 | } |
| 2825 | int intintIdentitySentinelPerfectOpenMPHash_EmptyTable(intintHash_Table * table) { |
| 2826 | int exitCode = 0; |
| 2827 | intintIdentitySentinelPerfectOpenMPHash_Bucket *buckets = |
| 2828 | (intintIdentitySentinelPerfectOpenMPHash_Bucket *) & table-> |
| 2829 | tableData[sizeof |
| 2830 | (intintIdentitySentinelPerfectOpenMPHash_TableData)]; |
| 2831 | int index; |
| 2832 | for (index = 0; |
| 2833 | index < |
| 2834 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) table-> |
| 2835 | tableData)->numBuckets; index++) { |
| 2836 | buckets[index].value = |
| 2837 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) |
| 2838 | table->tableData)->emptyValue; |
| 2839 | } |
| 2840 | exitCode = HASH_EXIT_CODE_NORMAL; |
| 2841 | return exitCode; |
| 2842 | } |
| 2843 | int intintIdentitySentinelPerfectOpenMPHash_InnerQuerySingle(char *tableData, |
| 2844 | int key, |
| 2845 | int *valueOutput) { |
| 2846 | intintIdentitySentinelPerfectOpenMPHash_Bucket *buckets = |
| 2847 | (intintIdentitySentinelPerfectOpenMPHash_Bucket *) & |
| 2848 | tableData[sizeof |
| 2849 | (intintIdentitySentinelPerfectOpenMPHash_TableData)]; |
| 2850 | int index; |
| 2851 | int exitCode; |
| 2852 | index = |
| 2853 | intintHash_CompressIdentity(((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 2854 | if (buckets[index].value != |
| 2855 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)-> |
| 2856 | emptyValue) { |
| 2857 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 2858 | } else { |
| 2859 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 2860 | } |
| 2861 | switch (exitCode) { |
| 2862 | case HASH_SEARCH_CODE_MATCH: |
| 2863 | *valueOutput = buckets[index].value; |
| 2864 | return HASH_EXIT_CODE_NORMAL; |
| 2865 | case HASH_SEARCH_CODE_MISMATCH: |
| 2866 | case HASH_SEARCH_CODE_EMPTY: |
| 2867 | return HASH_EXIT_CODE_KEY_DNE; |
| 2868 | default: |
| 2869 | return exitCode; |
| 2870 | } |
| 2871 | } |
| 2872 | int intintIdentitySentinelPerfectOpenMPHash_InnerQuery(char *tableData, |
| 2873 | unsigned int numKeys, |
| 2874 | int *keys, |
| 2875 | int *valuesOutput) { |
| 2876 | intintIdentitySentinelPerfectOpenMPHash_Bucket *buckets = |
| 2877 | (intintIdentitySentinelPerfectOpenMPHash_Bucket *) & |
| 2878 | tableData[sizeof |
| 2879 | (intintIdentitySentinelPerfectOpenMPHash_TableData)]; |
| 2880 | int key; |
| 2881 | int *valueOutput; |
| 2882 | int index; |
| 2883 | int exitCode; |
| 2884 | uint i; |
| 2885 | int resultExitCode = HASH_EXIT_CODE_NORMAL; |
| 2886 | for (i = 0; i < numKeys; i++) { |
| 2887 | key = keys[i]; |
| 2888 | valueOutput = &valuesOutput[i]; |
| 2889 | index = |
| 2890 | intintHash_CompressIdentity(((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 2891 | if (buckets[index].value != |
| 2892 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) |
| 2893 | tableData)->emptyValue) { |
| 2894 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 2895 | } else { |
| 2896 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 2897 | } |
| 2898 | switch (exitCode) { |
| 2899 | case HASH_SEARCH_CODE_MATCH: |
| 2900 | *valueOutput = buckets[index].value; |
| 2901 | break; |
| 2902 | case HASH_SEARCH_CODE_MISMATCH: |
| 2903 | case HASH_SEARCH_CODE_EMPTY: |
| 2904 | resultExitCode = HASH_EXIT_CODE_KEY_DNE; |
| 2905 | break; |
| 2906 | default: |
| 2907 | return exitCode; |
| 2908 | } |
| 2909 | } |
| 2910 | return resultExitCode; |
| 2911 | } |
| 2912 | int intintIdentitySentinelPerfectOpenMPHash_InnerInsertSingle(char *tableData, |
| 2913 | int key, |
| 2914 | int value) { |
| 2915 | intintIdentitySentinelPerfectOpenMPHash_Bucket *buckets = |
| 2916 | (intintIdentitySentinelPerfectOpenMPHash_Bucket *) & |
| 2917 | tableData[sizeof |
| 2918 | (intintIdentitySentinelPerfectOpenMPHash_TableData)]; |
| 2919 | int index; |
| 2920 | int exitCode; |
| 2921 | index = |
| 2922 | intintHash_CompressIdentity(((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 2923 | if (buckets[index].value != |
| 2924 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)-> |
| 2925 | emptyValue) { |
| 2926 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 2927 | } else { |
| 2928 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 2929 | } |
| 2930 | switch (exitCode) { |
| 2931 | case HASH_SEARCH_CODE_MATCH: |
| 2932 | case HASH_SEARCH_CODE_MISMATCH: |
| 2933 | buckets[index].value = value; |
| 2934 | return HASH_EXIT_CODE_OVERWRITE; |
| 2935 | case HASH_SEARCH_CODE_EMPTY: |
| 2936 | buckets[index].value = value; |
| 2937 | return HASH_EXIT_CODE_NORMAL; |
| 2938 | default: |
| 2939 | return exitCode; |
| 2940 | } |
| 2941 | } |
| 2942 | int intintIdentitySentinelPerfectOpenMPHash_InnerInsert(char *tableData, |
| 2943 | unsigned int numEntries, |
| 2944 | int *keys, |
| 2945 | int *values) { |
| 2946 | intintIdentitySentinelPerfectOpenMPHash_Bucket *buckets = |
| 2947 | (intintIdentitySentinelPerfectOpenMPHash_Bucket *) & |
| 2948 | tableData[sizeof |
| 2949 | (intintIdentitySentinelPerfectOpenMPHash_TableData)]; |
| 2950 | int resultExitCode = HASH_EXIT_CODE_NORMAL; |
| 2951 | int key; |
| 2952 | int value; |
| 2953 | int index; |
| 2954 | int exitCode; |
| 2955 | uint i; |
| 2956 | for (i = 0; i < numEntries; i++) { |
| 2957 | key = keys[i]; |
| 2958 | index = |
| 2959 | intintHash_CompressIdentity(((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 2960 | if (buckets[index].value != |
| 2961 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) |
| 2962 | tableData)->emptyValue) { |
| 2963 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 2964 | } else { |
| 2965 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 2966 | } |
| 2967 | switch (exitCode) { |
| 2968 | case HASH_SEARCH_CODE_MATCH: |
| 2969 | case HASH_SEARCH_CODE_MISMATCH: |
| 2970 | resultExitCode = HASH_EXIT_CODE_OVERWRITE; |
| 2971 | case HASH_SEARCH_CODE_EMPTY: |
| 2972 | buckets[index].value = values[i]; |
| 2973 | break; |
| 2974 | default: |
| 2975 | return exitCode; |
| 2976 | } |
| 2977 | } |
| 2978 | return resultExitCode; |
| 2979 | } |
| 2980 | int intintIdentitySentinelPerfectOpenMPHash_InnerInsertSingleNoOverwrite(char |
| 2981 | *tableData, |
| 2982 | int |
| 2983 | key, |
| 2984 | int |
| 2985 | value) |
| 2986 | { |
| 2987 | intintIdentitySentinelPerfectOpenMPHash_Bucket *buckets = |
| 2988 | (intintIdentitySentinelPerfectOpenMPHash_Bucket *) & |
| 2989 | tableData[sizeof |
| 2990 | (intintIdentitySentinelPerfectOpenMPHash_TableData)]; |
| 2991 | int index; |
| 2992 | int exitCode; |
| 2993 | index = |
| 2994 | intintHash_CompressIdentity(((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 2995 | if (buckets[index].value != |
| 2996 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)-> |
| 2997 | emptyValue) { |
| 2998 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 2999 | } else { |
| 3000 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 3001 | } |
| 3002 | switch (exitCode) { |
| 3003 | case HASH_SEARCH_CODE_MATCH: |
| 3004 | case HASH_SEARCH_CODE_MISMATCH: |
| 3005 | return HASH_EXIT_CODE_OVERWRITE; |
| 3006 | case HASH_SEARCH_CODE_EMPTY: |
| 3007 | buckets[index].value = value; |
| 3008 | return HASH_EXIT_CODE_NORMAL; |
| 3009 | default: |
| 3010 | return exitCode; |
| 3011 | } |
| 3012 | } |
| 3013 | int intintIdentitySentinelPerfectOpenMPHash_InnerInsertNoOverwrite(char |
| 3014 | *tableData, |
| 3015 | unsigned int |
| 3016 | numEntries, |
| 3017 | int *keys, |
| 3018 | int *values) |
| 3019 | { |
| 3020 | intintIdentitySentinelPerfectOpenMPHash_Bucket *buckets = |
| 3021 | (intintIdentitySentinelPerfectOpenMPHash_Bucket *) & |
| 3022 | tableData[sizeof |
| 3023 | (intintIdentitySentinelPerfectOpenMPHash_TableData)]; |
| 3024 | int resultExitCode = HASH_EXIT_CODE_NORMAL; |
| 3025 | int key; |
| 3026 | int value; |
| 3027 | int index; |
| 3028 | int exitCode; |
| 3029 | uint i; |
| 3030 | for (i = 0; i < numEntries; i++) { |
| 3031 | key = keys[i]; |
| 3032 | index = |
| 3033 | intintHash_CompressIdentity(((intintIdentitySentinelPerfectOpenMPHash_TableData *) tableData)->compressFuncData, key); |
| 3034 | if (buckets[index].value != |
| 3035 | ((intintIdentitySentinelPerfectOpenMPHash_TableData *) |
| 3036 | tableData)->emptyValue) { |
| 3037 | exitCode = HASH_SEARCH_CODE_MATCH; |
| 3038 | } else { |
| 3039 | exitCode = HASH_SEARCH_CODE_EMPTY; |
| 3040 | } |
| 3041 | switch (exitCode) { |
| 3042 | case HASH_SEARCH_CODE_MATCH: |
| 3043 | case HASH_SEARCH_CODE_MISMATCH: |
| 3044 | resultExitCode = HASH_EXIT_CODE_OVERWRITE; |
| 3045 | break; |
| 3046 | case HASH_SEARCH_CODE_EMPTY: |
| 3047 | buckets[index].value = values[i]; |
| 3048 | break; |
| 3049 | default: |
| 3050 | return exitCode; |
| 3051 | } |
| 3052 | } |
| 3053 | return resultExitCode; |
| 3054 | } |
| 3055 | int intintIdentitySentinelPerfectOpenMPHash_QuerySingle(intintHash_Table * |
| 3056 | table, int key, |
| 3057 | int *valueOutput) { |
| 3058 | return intintIdentitySentinelPerfectOpenMPHash_InnerQuerySingle(table-> |
| 3059 | tableData, |
| 3060 | key, |
| 3061 | valueOutput); |
| 3062 | } |
| 3063 | int intintIdentitySentinelPerfectOpenMPHash_Query(intintHash_Table * table, |
| 3064 | size_t numKeys, int *keys, |
| 3065 | int *valuesOutput) { |
| 3066 | return intintIdentitySentinelPerfectOpenMPHash_InnerQuery(table-> |
| 3067 | tableData, |
| 3068 | numKeys, keys, |
| 3069 | valuesOutput); |
| 3070 | } |
| 3071 | int intintIdentitySentinelPerfectOpenMPHash_InsertSingle(intintHash_Table * |
| 3072 | table, int key, |
| 3073 | int value) { |
| 3074 | return intintIdentitySentinelPerfectOpenMPHash_InnerInsertSingle(table-> |
| 3075 | tableData, |
| 3076 | key, |
| 3077 | value); |
| 3078 | } |
| 3079 | int intintIdentitySentinelPerfectOpenMPHash_Insert(intintHash_Table * table, |
| 3080 | size_t numEntries, int *keys, |
| 3081 | int *values) { |
| 3082 | return intintIdentitySentinelPerfectOpenMPHash_InnerInsert(table-> |
| 3083 | tableData, |
| 3084 | numEntries, |
| 3085 | keys, |
| 3086 | values); |
| 3087 | } |
| 3088 | int |
| 3089 | intintIdentitySentinelPerfectOpenMPHash_InsertSingleNoOverwrite(intintHash_Table |
| 3090 | * table, |
| 3091 | int key, |
| 3092 | int value) { |
| 3093 | return |
| 3094 | intintIdentitySentinelPerfectOpenMPHash_InnerInsertSingleNoOverwrite |
| 3095 | (table->tableData, key, value); |
| 3096 | } |
| 3097 | int intintIdentitySentinelPerfectOpenMPHash_InsertNoOverwrite(intintHash_Table * |
| 3098 | table, |
| 3099 | size_t numEntries, |
| 3100 | int *keys, |
| 3101 | int *values) { |
| 3102 | return |
| 3103 | intintIdentitySentinelPerfectOpenMPHash_InnerInsertNoOverwrite |
| 3104 | (table->tableData, numEntries, keys, values); |
| 3105 | } |
| 3106 | |
| 2405 | 3107 | typedef struct intintLCGLinearOpenCompactHash_TableData { |
| 2406 | 3108 | int hashID; |
| 2407 | 3109 | unsigned int numBuckets; |